]> gitweb.factorcode.org Git - factor.git/commitdiff
io.files.info.unix: errno EACCES should be handled separately.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 25 Oct 2012 00:50:45 +0000 (17:50 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 25 Oct 2012 00:51:13 +0000 (17:51 -0700)
basis/io/files/info/unix/unix.factor

index a39999a0bc4c9fb5a7b6b3ae9cd54f81ef50a5fe..4646d360f4b5cb581c66bec0a02b697577b88414 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.data arrays calendar
 calendar.unix classes.struct combinators
-combinators.short-circuit io.backend
-io.files.info io.files.types kernel literals math math.bitwise
+combinators.short-circuit io.backend io.files.info
+io.files.types kernel libc literals math math.bitwise
 sequences specialized-arrays strings system unix unix.ffi
 unix.groups unix.stat unix.time unix.users vocabs ;
 IN: io.files.info.unix
@@ -284,8 +284,17 @@ PRIVATE>
         [ drop file-type>executable ]
     } case ;
 
-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 ;
+<PRIVATE
+
+: access? ( path mode -- ? )
+    [ normalize-path ] [ access ] bi* 0 < [
+        errno EACCES = [ f ] [ (io-error) ] if
+    ] [ t ] if ;
+
+PRIVATE>
+
+M: unix file-readable? R_OK access? ;
+M: unix file-writable? W_OK access? ;
+M: unix file-executable? X_OK access? ;
 
 "io.files.info.unix." os name>> append require