io.files.info: adding checks for read, write, or execute permissions.
parent
98b52e624c
commit
37bb5f6917
|
@ -1,4 +1,4 @@
|
|||
USING: help.markup help.syntax arrays io.files ;
|
||||
USING: arrays help.markup help.syntax kernel io.files ;
|
||||
IN: io.files.info
|
||||
|
||||
HELP: file-info
|
||||
|
@ -37,6 +37,18 @@ HELP: file-system-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
|
||||
|
@ -51,6 +63,12 @@ ARTICLE: "io.files.info" "File system meta-data"
|
|||
{ $subsections
|
||||
file-system-info
|
||||
file-systems
|
||||
}
|
||||
"File permissions:"
|
||||
{ $subsections
|
||||
file-readable?
|
||||
file-writable?
|
||||
file-executable?
|
||||
} ;
|
||||
|
||||
ABOUT: "io.files.info"
|
||||
|
|
|
@ -25,6 +25,10 @@ available-space free-space used-space total-space ;
|
|||
|
||||
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" ] }
|
||||
|
|
|
@ -284,4 +284,8 @@ PRIVATE>
|
|||
[ 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
|
||||
|
|
Loading…
Reference in New Issue