Jump to content

ManagedMassStorage: Difference between revisions

From Advanced Computers Wiki
No edit summary
No edit summary
Line 76: Line 76:
|Writes the given string to the handle's current position.
|Writes the given string to the handle's current position.
|- style="white-space: nowrap;" |
|- style="white-space: nowrap;" |
|<code>:seek(string:relativeTo, integer:offset)</code>
|<code>:seek(string:relativeTo, integer:offset)</code>  
|<code>integer</code>
|<code>integer</code>
|Adjusts the handle's current position as specified by <code>relativeTo</code> and <code>offset</code>.  
|style="white-space: wrap;" |Adjusts the handle's current position as specified by <code>relativeTo</code> and <code>offset</code>. Valid values for relativeTo are <code>start</code>, <code>end</code> and <code>relative</code>.
Valid values for relativeTo are <code>start</code>, <code>end</code> and <code>relative</code>.
|-
|-
|<code>:flush()</code>
|<code>:flush()</code>

Revision as of 01:56, 2 August 2026

The ManagedMassStorageUD component is what backs Hard Disk Drives and Floppy Disks. This virtual component offers the following properties:

ManagedMassStorageUD component properties
Name Type Read/Write Description
totalCapacityBytes integer READ Total capacity of this drive (capacity is currently not limited, so this is not meaningful currently)
ManagedMassStorageUD component methods
Name Returns Description
:open(string:filePath[, string:mode=r]) LuaFsFileUD
mode Attempted action
r Open an existing file in read-only mode.
r+ Open an existing file in read-write mode.
w Open a potentially existent file, erase the contents and open it in write-only mode.
w+ Same as w but also allows reading.
a Open or create a new file, do not erase the contents, allow only appending.
:list(string:path) string[] Returns a list of absolute paths to files in the given directory.
:fileExists(string:path) boolean Returns whether the given path exists and represents a file
:directoryExists(string:path) string[] Returns whether the given path exists and represents a directory
:delete(string:path) void Deletes the specified file or directory. Directories are deleted recursively.
:move(string:srcPath, string:destPath) void Moves the specified file or directory to the destination path.
:makeDirection(string:path) void Creates a new directory at the specified path.
:spaceUsed([string:path="/"]) long Returns the amount of space used on this storage device. If a path is given, only the space in this directory is measured.

LuaFsFileUD

ManagedMassStorageUD component methods
Name Returns Description
:read(integer:count) string? Reads a string from the handle's current position. Reads as much as possible, but at most count characters. If count is set to -1, as many chracters as possible are returned.
:write(string:s) void Writes the given string to the handle's current position.
:seek(string:relativeTo, integer:offset) integer Adjusts the handle's current position as specified by relativeTo and offset. Valid values for relativeTo are start, end and relative.
:flush() void Writes all changes to the host filesystem.
:close() void Closes the handle, automatically flushing.