REBOL Programming/clean-path

From Wikibooks, open books for an open world
< REBOL Programming
Jump to: navigation, search

USAGE:[edit]

CLEAN-PATH target 

DESCRIPTION:[edit]

Cleans-up '.' and '..' in path; returns the cleaned path.

CLEAN-PATH is a function value.

ARGUMENTS[edit]

  • target -- (Type: file url)

SOURCE CODE[edit]

clean-path: func [
    {Cleans-up '.' and '..' in path; returns the cleaned path.} 
    target [file! url!]
][
    if url? target [return target] 
    if find [%/ %/. %/..] target [return %/] 
    get-modes target 'full-path
]