< Rebol Programming
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!) (Type: 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 CODE
to-relative-file: func [ {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" /local tmp ][ either string? file [ if tmp: find/match file to-local-file what-dir [file: next tmp] 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 ]
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.