! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types alien.strings combinators
-continuations destructors fry io io.backend io.backend.unix
-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 ;
+USING: accessors alien.c-types alien.data alien.strings
+combinators continuations destructors fry io io.backend
+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 libc vocabs ;
IN: io.directories.unix
-: touch-mode ( -- n )
- { O_WRONLY O_APPEND O_CREAT O_EXCL } flags ; foldable
+CONSTANT: file-mode 0o0666
+
+CONSTANT: touch-mode flags{ O_WRONLY O_APPEND O_CREAT O_EXCL }
M: unix touch-file ( path -- )
normalize-path
] if ;
M: unix move-file ( from to -- )
- [ normalize-path ] bi@ rename io-error ;
+ [ normalize-path ] bi@ [ rename ] unix-system-call drop ;
M: unix delete-file ( path -- ) normalize-path unlink-file ;
M: unix make-directory ( path -- )
- normalize-path OCT: 777 mkdir io-error ;
+ normalize-path 0o777 [ mkdir ] unix-system-call drop ;
M: unix delete-directory ( path -- )
- normalize-path rmdir io-error ;
+ normalize-path [ rmdir ] unix-system-call drop ;
M: unix copy-file ( from to -- )
[ normalize-path ] bi@ call-next-method ;
M: unix find-next-file ( DIR* -- byte-array )
dirent <struct>
- f <void*>
- [ readdir_r 0 = [ (io-error) ] unless ] 2keep
- *void* [ drop f ] unless ;
+ f void* <ref>
+ 0 set-errno
+ [ readdir_r 0 = [ errno 0 = [ (io-error) ] unless ] unless ] 2keep
+ void* deref [ drop f ] unless ;
: dirent-type>file-type ( ch -- type )
{