UCE Docs / file_temp

Signature

String file_temp(String prefix)

Parameters

prefix : path prefix for the temp file; a unique suffix is appended
return value : the path of the newly created temp file, or "" on failure

Creates a new, uniquely named empty file using prefix as the leading path and returns its full path. Use it for scratch files and the write-then-rename publish pattern.

Example

String path = file_temp("/tmp/doc-temp-");
file_put_contents(path, "scratch");
print(str_starts_with(path, "/tmp/doc-temp-") ? "created a temp file" : path, "\n");
file_unlink(path);
Output
created a temp file