CONSTANT: mkdir-mode flags{ USER-ALL GROUP-ALL OTHER-ALL } ! 0o777
-M: unix touch-file ( path -- )
+M: unix touch-file
normalize-path
dup exists? [ touch ] [
touch-mode file-mode open-file close-file
] if ;
-M: unix move-file-atomically ( from to -- )
+M: unix move-file-atomically
[ normalize-path ] bi@ [ rename ] unix-system-call drop ;
-M: unix move-file ( from to -- )
+M: unix move-file
[ move-file-atomically ] [
dup errno>> EXDEV = [
drop [ copy-file ] [ drop delete-file ] 2bi
] [ rethrow ] if
] recover ;
-M: unix delete-file ( path -- ) normalize-path unlink-file ;
+M: unix delete-file normalize-path unlink-file ;
-M: unix make-directory ( path -- )
+M: unix make-directory
normalize-path mkdir-mode [ mkdir ] unix-system-call drop ;
-M: unix delete-directory ( path -- )
+M: unix delete-directory
normalize-path [ rmdir ] unix-system-call drop ;
-M: unix copy-file ( from to -- )
+M: unix copy-file
[ call-next-method ]
[ [ file-permissions ] dip swap set-file-permissions ] 2bi ;
dup +unknown+ = [ drop dup file-info type>> ] when
<directory-entry> ; inline
-M: unix (directory-entries) ( path -- seq )
+M: unix (directory-entries)
[
dirent <struct>
'[ _ _ next-dirent ] [ >directory-entry ] produce nip