-
Notifications
You must be signed in to change notification settings - Fork 1
FileExists
ricardoboss edited this page Sep 13, 2023
·
1 revision
The fileExists
function checks if a file at the given path exists and returns a boolean indicating the result.
fileExists(string path)
-
path
is the path to a file or link/junction to a file.
- The function only checks if the file exists, not if it can be read using
fileRead
(so it may exist but is currently not readable) - The path can be relative and is interpreted relative to the current working directory
- Absolute paths may require a drive letter (system dependent)
/
data/
a.txt
b.txt
lib/
main.step
c.txt
lib/main.step
run in /lib/
:
if (fileExists("/data/a.txt")) {
println("/data/a.txt found") // will get printed
}
if (fileExists("b.txt")) {
println("b.txt in current dir found") // will NOT get printed
}
if (fileExists("c.txt")) {
println("c.txt in current dir found") // will get printed
}
© 2023 Ricardo Boss • Licensed under MIT • Want to update this page? Edit it on GitHub and submit a pull request!