20 lines
636 B
Plaintext
20 lines
636 B
Plaintext
:sig
|
|
bool file_exists(String path)
|
|
|
|
:params
|
|
path : path to check, resolved against the unit's directory
|
|
return value : true if a regular file exists at `path`
|
|
|
|
:content
|
|
Reports whether a regular file exists. Use it to guard reads or to confirm a write or delete took effect. It is file-oriented and returns false for directories — use `file_stat()` and check `is_dir` to test for a directory.
|
|
|
|
:example
|
|
file_put_contents("/tmp/doc-exists.txt", "x");
|
|
print(file_exists("/tmp/doc-exists.txt") ? "exists" : "missing", " / ");
|
|
print(file_exists("/tmp/doc-not-here-xyz.txt") ? "exists" : "missing", "\n");
|
|
|
|
:see
|
|
>sys
|
|
file_stat
|
|
file_unlink
|