Files documentation
Introductions
The 'files' API is what gives lua programs the ability to interact with the parent computers folders, partitions and disks or generate file headers, it is not the API for the files themselves, to read/write/append to files, view the file header documentation.
File paths are usually in the following format: "(partition):/(filename).(extension)" or "(partition):/(directory)/(filename).(extension)", and the disk number to operate on is a separate parameter, starting at zero
The file system also contains the ability to interface with multiple disks,
disk 0 is the home disk containing the computers internal files, and has appropriate restrictions.
some disks are 'bootable' and contain an entrypoint for execution of the disks program contents, home disks with
an entrypoint to a non-existent file will fail to boot, and disks that contain an entrypoint can be crafted into the home disk of a new computer block.
The files api exists in the global space as "files" or "_G.files"
Lookup table
| getPartitions(disk = 0) | Returns the systems partitions as a list of names |
| getPartition(name, disk = 0) | Returns a table with basic information about the partition |
| createPartition(name, disk = 0) | Creates a default partition with the given name |
| deletePartition(name, disk = 0) | Attempts to delete a partition with the given name |
| setPartitionHidden(name, state, disk = 0) | Sets a partitions hidden quality |
| setPartitionReadOnly(name, disk = 0) | Makes a partition read only |
| open(path, mode='r', disk = 0) | Opens a file header representing the file at the path, in the given mode |
| getChildren(path, disk = 0) | returns a list of the sub-paths of the directory at the path |
| makeDir(path, disk = 0) | Attempts to make a directory at the path |
| exists(path, disk = 0) | Probes to see if a path exists |
| isFile(path, disk = 0) | Probes to see if a path exists and isn't a directory |
| isDir(path, disk = 0) | Probes to see if a path exists and is a directory |
| delete(path, disk = 0) | Attempts to delete the data at the path |
| getNumberOfDisks() | Counts the amount of disks on the system |
| getDisks() | Counts the numbers of the disks on the system |
| getDiskID(disk) | Gets the UUID of the disk |
| removeDisk(disk) | Attempts to detach the disk |
| getBootPath(disk) | Gets the entrypoint for a disk or nil |
| setBoot(entrypoint, disk) | Attempts to set the boot data of a disk |
| setBoot(disk) | Attempts to remove boot information from a disk |
Functions in detail
getPartitions(disk = 0)
Returns a list of partition names belonging to the filesystem
Parameters: Disk[Integer] default value 0 Returns: [String]getPartition(name, disk = 0)
Gets a table of data relating to the partition named, if it exists
Parameters: Name[String], Disk[Integer] default value 0 Returns: {name: String, readonly: Bool, hidden: Bool} or nilcreatePartition(name, disk = 0)
Creates a non-hidden, writable partition with the given name, if available. And indicates if the partition was created
Parameters: Name[String], Disk[Integer] default value 0 Returns: BooldeletePartition(name, disk = 0)
Attempts to delete a partition with the given name
Parameters: Name[String], Disk[Integer] default value 0 Returns: BoolsetPartitionHidden(name, state, disk = 0)
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], Disk[Integer] default value 0 Returns: BoolsetPartitionReadOnly(name, disk = 0)
Mark the given partition as read only, after its contents won't be editable
Parameters: Name[String], Disk[Integer] default value 0 Returns: Boolopen(path, mode='r', disk = 0)
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", Disk[Integer] default value 0 Returns: APITablegetChildren(path, disk = 0)
Returns a list of the paths of the files inside the directory indicated by the parameters
Parameters: Path[String], Disk[Integer] default value 0 Returns: [String]makeDir(path, disk = 0)
Attempts to make directory at the path
Parameters: Path[String], Disk[Integer] default value 0 Returns: Boolexists(path, disk = 0)
Checks if the path contains data
Parameters: Path[String], Disk[Integer] default value 0 Returns: BoolisFile(path, disk = 0)
Checks if the file first exists and then is a file / not a directory
Parameters: Path[String], Disk[Integer] default value 0 Returns: BoolisDir(path, disk = 0)
Checks if the file first exists and then is not a file / a directory
Parameters: Path[String], Disk[Integer] default value 0 Returns: Booldelete(path, disk = 0)
Attempts to delete the data at the path and returns if the operation was a success
Parameters: Path[String], Disk[Integer] default value 0 Returns: BoolgetNumberOfDisks()
Counts the amount of disks on the system
Parameters: None Returns: [Integer]getDisks()
Counts the numbers of the disks on the system
Parameters: None Returns: [list of Integers]]getDiskID(disk)
Gets the UUID of the disk
Parameters: Disk[Integer] Returns: [String]removeDisk(disk)
Attempts to detach the disk, will always fail to delete the home disk
Parameters: Disk[Integer] Returns: [Boolean]getBootPath(disk)
Gets the entrypoint for a disk or nil if the disk is not bootable
Parameters: Disk[Integer] Returns: [String or nil]setBoot(entrypoint, disk)
Attempts to set the boot data of a disk, will preform an additional safety check to ensure the entrypoint exists exclusively for the home disk
Parameters: Entrypoint[String], Disk[Integer] Returns: [Boolean]setBoot(disk)
Attempts to remove boot information from a disk, will always fail for the home disk
Parameters: Disk[Integer] Returns: [Boolean]