uce/site/doc/pages/file_rename.txt
2026-06-16 23:02:45 +00:00

21 lines
590 B
Plaintext

:sig
bool file_rename(String from, String to)
:params
from : source path
to : destination path
return value : true on success
:content
Renames or moves a file. After a successful rename the source path no longer exists. Use it for atomic publish patterns: write a temp file, then rename it into place.
:example
file_put_contents("/tmp/doc-rename-a.txt", "moved");
file_rename("/tmp/doc-rename-a.txt", "/tmp/doc-rename-b.txt");
print(file_get_contents("/tmp/doc-rename-b.txt"), " / source ", file_exists("/tmp/doc-rename-a.txt") ? "exists" : "gone", "\n");
:see
>sys
file_copy
file_temp