move-file ( from to -- ) (original) (raw)
move-file ( from to -- )
Factor handbook » Input and output » Directory manipulation » Deleting, moving, and copying files
Prev: | delete-directory ( path -- ) |
---|---|
Next: | move-file-into ( from to -- ) |
Vocabulary
io.directories
Inputs
from | a pathname string |
---|---|
to | a pathname string |
Outputs
None
Word description
Moves or renames a file. This operation is not guaranteed to be atomic. In particular, if you attempt to move a file across volumes, this will copy the file and then delete the original in a nontransactional manner.
Errors
Throws an error if the file does not exist or if the move operation fails.
See also
move-file-atomically
Definition
HOOK: move-file io-backend ( from to -- )
Methods
USING: accessors continuations io.directories kernel libc system
;
M: unix move-file
[ move-file-atomically ] [
dup errno>> EXDEV =
[ drop [ copy-file ] [ drop delete-file ] 2bi ]
[ rethrow ] if
] recover ;