io.files.info: Add file? and symlink? words.

db4
Doug Coleman 2013-04-18 07:35:47 -07:00
parent 02d652e6c0
commit 345b5bb678
2 changed files with 12 additions and 0 deletions
basis/io/files/info

View File

@ -16,6 +16,14 @@ HELP: directory?
{ $values { "file-info" file-info } { "?" "a boolean" } }
{ $description "Tests if " { $snippet "file-info" } " is a directory." } ;
HELP: file?
{ $values { "file-info" file-info } { "?" "a boolean" } }
{ $description "Tests if " { $snippet "file-info" } " is a file." } ;
HELP: symlink?
{ $values { "file-info" file-info } { "?" "a boolean" } }
{ $description "Tests if " { $snippet "file-info" } " is a symlink." } ;
HELP: file-systems
{ $values { "array" array } }
{ $description "Returns an array of " { $link file-system-info } " objects returned by iterating the mount points and calling " { $link file-system-info } " on each." } ;
@ -59,6 +67,8 @@ ARTICLE: "io.files.info" "File system meta-data"
link-info
exists?
directory?
file?
symlink?
}
"File types:"
{ $subsections "file-types" }

View File

@ -13,6 +13,8 @@ HOOK: file-info os ( path -- info )
HOOK: link-info os ( path -- info )
: directory? ( file-info -- ? ) type>> +directory+ = ;
: file? ( file-info -- ? ) type>> +regular-file+ = ;
: symlink? ( file-info -- ? ) type>> +symbolic-link+ = ;
: sparse-file? ( file-info -- ? )
[ size-on-disk>> ] [ size>> ] bi < ;