]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/io/directories/unix/unix.factor
io.directories: improve file moving words
[factor.git] / basis / io / directories / unix / unix.factor
index 3cc0b549e824df2befc5d5d1b5ba7058d2688ff9..14a37f5bedf2fd5802527f6273fd63d69bc51ce8 100644 (file)
@@ -17,9 +17,16 @@ M: unix touch-file ( path -- )
         touch-mode file-mode open-file close-file
     ] if ;
 
-M: unix move-file ( from to -- )
+M: unix move-file-atomically ( from to -- )
     [ normalize-path ] bi@ [ rename ] unix-system-call drop ;
 
+M: unix move-file ( from to -- )
+    [ 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 make-directory ( path -- )