]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/io/directories/unix/unix.factor
use radix literals
[factor.git] / basis / io / directories / unix / unix.factor
index d5dc0ab90575cd3357f5ebddbd05f44fc85d3ffd..eabf1bf314445062ef165b2264c17b0f5a928c97 100644 (file)
@@ -2,12 +2,14 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.data alien.strings
 combinators continuations destructors fry io io.backend
-io.backend.unix io.directories io.encodings.binary
+io.directories io.encodings.binary
 io.encodings.utf8 io.files io.pathnames io.files.types kernel
 math.bitwise sequences system unix unix.stat vocabs.loader
-classes.struct unix.ffi literals ;
+classes.struct unix.ffi literals libc vocabs ;
 IN: io.directories.unix
 
+CONSTANT: file-mode 0o0666
+
 CONSTANT: touch-mode flags{ O_WRONLY O_APPEND O_CREAT O_EXCL }
 
 M: unix touch-file ( path -- )
@@ -22,7 +24,7 @@ M: unix move-file ( from to -- )
 M: unix delete-file ( path -- ) normalize-path unlink-file ;
 
 M: unix make-directory ( path -- )
-    normalize-path OCT: 777 [ mkdir ] unix-system-call drop ;
+    normalize-path 0o777 [ mkdir ] unix-system-call drop ;
 
 M: unix delete-directory ( path -- )
     normalize-path [ rmdir ] unix-system-call drop ;
@@ -39,7 +41,8 @@ HOOK: find-next-file os ( DIR* -- byte-array )
 M: unix find-next-file ( DIR* -- byte-array )
     dirent <struct>
     f void* <ref>
-    [ readdir_r 0 = [ (io-error) ] unless ] 2keep
+    0 set-errno
+    [ readdir_r 0 = [ errno 0 = [ (io-error) ] unless ] unless ] 2keep
     void* deref [ drop f ] unless ;
 
 : dirent-type>file-type ( ch -- type )