Rebol 程式設計/to-relative-file
外觀
TO-RELATIVE-FILE file /no-copy /as-rebol /as-local
如果檔案在子目錄中,則返回檔案的相對部分,否則返回原始部分。
TO-RELATIVE-FILE 是一個函式值。
- file -- 要檢查的檔案(如果為字串,則為本地檔案)(型別: file string)
- /no-copy -- 不復制,只引用
- /as-rebol -- 如果不是,則轉換為 REBOL 風格的檔名
- /as-local -- 如果不是,則轉換為本地風格的檔名
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
]