Handbook
Glossary
safe-replace-file ( ..a original-path quot: ( ..a copy-path -- ..b ) -- ..b )
Unique files
Prev:
cleanup-unique-directory ( quot -- )
Next:
safe-overwrite-file ( ..a original-path quot: ( ..a empty-path -- ..b ) -- ..b )
Vocabulary
io
.
files
.
unique
Inputs
original-path
a pathname string
quot
a
quotation
Outputs
None
Word description
Copies the file from
original-path
to a unique file, applies the
quot
quotation to it, and then moves the unique file back atomically.
Definition
USING:
io.directories
kernel
;
IN:
io.files.unique
:
safe-replace-file
( ..a original-path quot: ( ..a copy-path -- ..b ) -- ..b )
[
""
""
]
dip
[
[
nip
]
]
dip
compose
[
[
[
copy-file
]
]
]
dip
[
[
swap
move-file-atomically
]
2tri
]
curry
compose
cleanup-unique-file
;
inline