Renames the file name_old to name_new, which may be on another volume. Returns false if that fails, including
when name_new already exists: delete it first, or see
File_Utilities.atomic_file_replace_or_just_rename_if_destination_file_does_not_exist.
file_move :: (name_old: string, name_new: string) -> bool
Parameters
- name_old: string
- name_new: string
Returns
- bool
#import "Extensions/Environment";
base := environment_variable("TMPDIR");
if base == "" base = environment_variable("TEMP");
if base == "" base = "/tmp";
path := tprint("%/jai-doc-move.bin", base);
defer file_delete(path);
to := tprint("%.moved", path);
defer file_delete(to);
assert(write_entire_file(path, "content"));
assert(file_move(path, to));
text, ok := read_entire_file(to);
assert(ok && text == "content");
free(text);
_, still_there := file_open(path);
assert(!still_there);Doesn't run in the browser (only on windows).