Rebol 编程/to-relative-file
外观
< Rebol 编程
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 ]