{ $example "USING: io.pathnames prettyprint ;" "\"/home/csi/gui.vbs\" file-stem ." "\"gui\"" }
} ;
-HELP: file-directory
-{ $values { "path" "a pathname string" } { "directory" string } }
-{ $description "Outputs the directory of " { $snippet "path" } " with the " { $link file-name } " removed, if any." }
-{ $examples
- { $example "USING: io.pathnames prettyprint ;" "\"/usr/bin/gcc\" file-directory ." "\"/usr/bin\"" }
- { $example "USING: io.pathnames prettyprint ;" "\"/home/csi/gui.vbs\" file-directory ." "\"/home/csi\"" }
-} ;
-
-{ file-name file-stem file-extension file-directory } related-words
+{ file-name file-stem file-extension } related-words
HELP: path-components
{ $values { "path" "a pathnames string" } { "seq" sequence } }
[ f ]
} cond ;
-: special-path ( path -- prefix )
- {
- { [ dup "resource:" head? ] [ drop "resource:" ] }
- { [ dup "vocab:" head? ] [ drop "vocab:" ] }
- [ drop "" ]
- } cond ;
-
PRIVATE>
: absolute-path? ( path -- ? )
: file-extension ( path -- extension )
file-name "." split1-last nip ;
-: file-directory ( path -- directory )
- [ special-path ] [ special-path? drop ] bi
- dup last-path-separator [ head append ] [ 2drop ] if
- [ path-separator ] when-empty ;
-
: path-components ( path -- seq )
normalize-path path-separator split harvest ;