file_exists
result =file_exists(path)/dir_exists(path)
Input: path · Output: result
What it is
Whether path (a Str) exists and is a regular file / a directory. A path that is not there at all is false, not an error — its absence is the answer you asked for.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = file_exists(path) / dir_exists(path) | path Strnot documented yet | result — | Returns a Bool. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
x = 1:10
print("sum = " + str(sum(x)))
write_report("summary.html")
print(file_exists("summary.html")) # true
output
sum = 55 true
from file-io
path = "touch_target.txt"
had_before = file_exists(path)
touch(path)
exists_after_touch = file_exists(path)
f = fopen(path, "w")
write_line(f, "original content")
close(f)
touch(path) # existing file: content must survive untouched
g = fopen(path, "r")
content = read_all(g)
close(g)
print("had_before = {had_before}")
print("exists_after_touch = {exists_after_touch}")
print("content = {content}")
from tour
See also
dir_exists — documented in the same entry.