From 83b40e44d23019774a8852ff4b70c210f8d9637c Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 24 Oct 2012 17:39:19 -0700 Subject: [PATCH] io.files.info: make access checks throw on file-does-not-exist. --- basis/io/files/info/info-docs.factor | 9 ++++++--- basis/io/files/info/unix/unix.factor | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/basis/io/files/info/info-docs.factor b/basis/io/files/info/info-docs.factor index 9b0c7a9046..98d05bab6f 100644 --- a/basis/io/files/info/info-docs.factor +++ b/basis/io/files/info/info-docs.factor @@ -39,15 +39,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." } ; +{ $description "Returns whether the file specified by " { $snippet "path" } " is readable by the current process." } +{ $errors "Throws an error if the file does not exist." } ; 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." } ; +{ $description "Returns whether the file specified by " { $snippet "path" } " is writable by the current process." } +{ $errors "Throws an error if the file does not exist." } ; 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." } ; +{ $description "Returns whether the file specified by " { $snippet "path" } " is executable by the current process." } +{ $errors "Throws an error if the file does not exist." } ; ARTICLE: "io.files.info" "File system meta-data" "File meta-data:" diff --git a/basis/io/files/info/unix/unix.factor b/basis/io/files/info/unix/unix.factor index 75da6d3716..a39999a0bc 100644 --- a/basis/io/files/info/unix/unix.factor +++ b/basis/io/files/info/unix/unix.factor @@ -284,8 +284,8 @@ PRIVATE> [ drop file-type>executable ] } case ; -M: unix file-readable? normalize-path flags{ F_OK R_OK } access 0 = ; -M: unix file-writable? normalize-path flags{ F_OK W_OK } access 0 = ; -M: unix file-executable? normalize-path flags{ F_OK X_OK } access 0 = ; +M: unix file-readable? normalize-path R_OK access io-error t ; +M: unix file-writable? normalize-path W_OK access io-error t ; +M: unix file-executable? normalize-path X_OK access io-error t ; "io.files.info.unix." os name>> append require