-USING: help.markup help.syntax arrays io.files ;
+USING: arrays help.markup help.syntax kernel io.files ;
IN: io.files.info
HELP: file-info
}
} ;
+HELP: file-readable?
+{ $values { "path" "a pathname string" } { "?" boolean } }
+{ $description "Returns whether the file specified by " { $snippet "path" } " exists and is readable by the current process." } ;
+
+HELP: file-writable?
+{ $values { "path" "a pathname string" } { "?" boolean } }
+{ $description "Returns whether the file specified by " { $snippet "path" } " exists and is writable by the current process." } ;
+
+HELP: file-executable?
+{ $values { "path" "a pathname string" } { "?" boolean } }
+{ $description "Returns whether the file specified by " { $snippet "path" } " exists and is executable by the current process." } ;
+
ARTICLE: "io.files.info" "File system meta-data"
"File meta-data:"
{ $subsections
{ $subsections
file-system-info
file-systems
+}
+"File permissions:"
+{ $subsections
+ file-readable?
+ file-writable?
+ file-executable?
} ;
ABOUT: "io.files.info"
HOOK: file-system-info os ( path -- file-system-info )
+HOOK: file-readable? os ( path -- ? )
+HOOK: file-writable? os ( path -- ? )
+HOOK: file-executable? os ( path -- ? )
+
{
{ [ os unix? ] [ "io.files.info.unix" ] }
{ [ os windows? ] [ "io.files.info.windows" ] }
[ drop file-type>executable ]
} case ;
+M: unix file-readable? flags{ F_OK R_OK } access 0 = ;
+M: unix file-writable? flags{ F_OK W_OK } access 0 = ;
+M: unix file-executable? flags{ F_OK X_OK } access 0 = ;
+
"io.files.info.unix." os name>> append require