Filesystem documentation
Introductions
The 'filesystem' API is what gives lua programs the ability to interact with the parent computers folders and partitions or generate file headers, it is not the API for the files themselves, to read/write/append to files, view the file header documentation.
The filesystem API is generated by using require 'file system', 'fs' and 'filesystem' are also valid aliases, and not case specific.
Lookup table
| getPartitions() | Returns the systems partitions as a list of names |
| getPartition(name) | Returns a table with basic information about the partition |
| createPartition(name) | Creates a default partition with the given name |
| setPartitionHidden(name, state) | Sets a partitions hidden quality |
| setPartitionReadOnly(name) | Makes a partition read only |
| open(path, mode='r') | Opens a file header representing the file at the path, in the given mode |
| getChildren(path) | returns a list of the sub-paths of the directory at the path |
| makeDir(path) | Attempts to make a directory at the path |
| exists(path) | Probes to see if a path exists |
| isFile(path) | Probes to see if a path exists and isn't a directory |
| isDir(path) | Probes to see if a path exists and is a directory |
| delete(path) | Attempts to delete the data at the path |
Functions in detail
getPartitions()
Returns a list of text containing the partitions belonging to the filesystem
Parameters: None Returns: [String]getPartition(name)
Gets a table of data relating to the partition named, if it exists
Parameters: Name[String] Returns: {name: String, readonly: Bool, hidden: Bool} or nilcreatePartition(name)
Creates a non-hidden, writable partition with the given name, if available. And indicates if the partition was created
Parameters: Name[String] Returns: BoolsetPartitionHidden(name, state)
Sets the given partition's hidden state to that given, if it exists. Notes that being hidden has no effect itself and is more individual programs to process (so completely useless, but I already added it so whatever).
Parameters: Name[String], State[Bool] Returns: BoolsetPartitionReadOnly(name)
Mark the given partition as read only, after its contents won't be editable
Parameters: Name[String] Returns: Boolopen(path, mode='r')
Opens up a file header for the file at the path, which uses the mode provided to set the rules of interaction with the file
file modes can be confusing, you can find a lookup table for every possible file mode here!
Parameters: Path[String], Mode[String] default value "r" Returns: APITablegetChildren(path)
Returns a list of the paths of the files inside the directory indicated by the parameters
Parameters: Path[String] Returns: [String]makeDir(path)
Attempts to make directory at the path
Parameters: Path[String] Returns: Boolexists(path)
Checks if the path contains data
Parameters: Path[String] Returns: BoolisFile(path)
Checks if the file first exists and then is a file / not a directory
Parameters: Path[String] Returns: BoolisDir(path)
Checks if the file first exists and then is not a file / a directory
Parameters: Path[String] Returns: Booldelete(path)
Attempts to delete the data at the path and returns if the operation was a success
Parameters: Path[String] Returns: Bool