Filesystem

Basic filesystem functions for basic filesystem needs.

Take caution when developing filesystem functions, these functions could cause catastrophic damage if you do not pay attention when developing.

-- Import the filesystem library.
local fs = require("@lib/filesystem")

writefile()

This function writes a file to the local filesystem, in a shared region.

-- Write a file.
fs.writefile(content: string, filename: string, location: string) -- Creates a new file if it doesn't exist, else it overrides.

-- Example
fs.writefile("These tacos are tasty, hawk tuah!", "what.txt", "./Yapping") -- Create a new folder if it doesn't exist.

readfile()

This is a potentially dangerous function and could lead to security issues.

This function reads a file from the local filesystem, in the shared folder. It is important you do not expose your environment to foreign files and restrict it to a shared region.

-- Read a file.
fs.readfile(file: string): string

-- Example
fs.readfile("./Yapping/what.txt") -- Errors if it could not find the file.

deletefile()

This is a dangerous function. Treat with caution.

This function deletes a file from the local filesystem, it is CRITICAL that you limit this function to the shared region and add safeguards to prevent operating system DESTRUCTION. Letting this function access foreign areas could cause CATASTROPHIC damage to the user.

-- DANGER: Deletes a file!
fs.deletefile(file: string): string

-- Example
fs.deletefile("./Yapping/what.txt") -- Errors if it could not find the file. Be careful when developing.

Last updated

Was this helpful?