To relative file

angerangel edited this page Jan 7, 2013 · 1 revision

USAGE

   TO-RELATIVE-FILE file /no-copy /as-rebol /as-local

DESCRIPTION

Returns the relative portion of a file if in a subdirectory, or the original if not.

TO-RELATIVE-FILE is a function value.

ARGUMENTS

  • file -- File to check (local if string!) (file! string!)

REFINEMENTS

  • /no-copy -- Don't copy, just reference
  • /as-rebol -- Convert to REBOL-style filename if not
  • /as-local -- Convert to local-style filename if not

#SOURCE

to-relative-file: make function! [  [
    {Returns the relative portion of a file if in a subdirectory, or the original if not.}
    file [file! string!] "File to check (local if string!)"
    /no-copy "Don't copy, just reference"
    /as-rebol "Convert to REBOL-style filename if not"
    /as-local "Convert to local-style filename if not"
][
    either string? file [
        file: any [find/match file to-local-file what-dir file]
        if as-rebol [file: to-rebol-file file no-copy: true]
    ] [
        file: any [find/match file what-dir file]
        if as-local [file: to-local-file file no-copy: true]
    ]
    unless no-copy [file: copy file]
    file
] ]
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.