File system library¶
This library is included by default, you don't need to import it.
Read¶
fs::read(p: string) -> string
Returns the contents of the file with path p.
Exists¶
fs::exists(p: string) -> bool
Returns whether or not the file p exists.
print(fs::exists("exists.txt")); // prints true
print(fs::exists("does_not_exist.txt")) // prints false
Write¶
fs::write(path: string, contents: string)
Writes contents to the file located at path, overwriting any existing content. Creates path if it doesn't exist.
Append¶
fs::append(path: string, contents: string)
Appends contents to the file located at path. Creates path if it doesn't exist.
Delete¶
fs::delete(path: string)
Deletes the file located at path. Crashes if the file doesn't exist.
DeleteDir¶
fs::delete_dir(path: string)
Deletes the empty folder located at path. Crashes if the folder doesn't exist or isn't empty.