Appearance
fs
The fs helper provides functions for interacting with the file system within the MARS Engine environment.
fs.exists(path)
Returns true if the file exists.
js
if (fs.exists("data.csv")) {
write("OK")
}fs.loadFile(path)
Returns the file object.
The file object has three attributes:
- name - Representing the name of the file
- contentType - Representing the type of content
- data - Binary file content
js
const text = fs.loadFile("hello.txt")fs.save(path, contents)
Writes string or buffer to a file. Overwrites if file exists.
js
fs.save("log.txt", "started")fs.delete(path)
Deletes a file.
js
fs.delete("old.csv")