Component/filesystem: Difference between revisions
Jump to navigation
Jump to search
imported>OCDoc Import Imported from legacy OpenComputers documentation at ocdoc.cil.li |
Clean up Markdown artifacts from DokuWiki migration |
||
| Line 3: | Line 3: | ||
This component is provided by [[Item/floppy disk|Floppy Disks]] or [[Item/hard disk drive|Hard Disk Drives]] in Managed mode (for Unmanaged mode, see [[Component/drive|Drive]]) | This component is provided by [[Item/floppy disk|Floppy Disks]] or [[Item/hard disk drive|Hard Disk Drives]] in Managed mode (for Unmanaged mode, see [[Component/drive|Drive]]) | ||
Component name: | Component name: <code>filesystem</code>. Callbacks: | ||
* | * <code>spaceUsed():number</code> | ||
<pre>The currently used capacity of the file system, in bytes. | <pre>The currently used capacity of the file system, in bytes. | ||
</pre> | </pre> | ||
* | * <code>open(path:string[, mode:string='r']):number</code> | ||
<pre>Opens a new file descriptor and returns its handle. | <pre>Opens a new file descriptor and returns its handle. | ||
</pre> | </pre> | ||
* | * <code>seek(handle:number, whence:string, offset:number):number</code> | ||
<pre>Seeks in an open file descriptor with the specified handle. Returns the new pointer position. | <pre>Seeks in an open file descriptor with the specified handle. Returns the new pointer position. | ||
</pre> | </pre> | ||
* | * <code>makeDirectory(path:string):boolean</code> | ||
<pre>Creates a directory at the specified absolute path in the file system. Creates parent directories, if necessary. | <pre>Creates a directory at the specified absolute path in the file system. Creates parent directories, if necessary. | ||
</pre> | </pre> | ||
* | * <code>exists(path:string):boolean</code> | ||
<pre>Returns whether an object exists at the specified absolute path in the file system. | <pre>Returns whether an object exists at the specified absolute path in the file system. | ||
</pre> | </pre> | ||
* | * <code>isReadOnly():boolean</code> | ||
<pre>Returns whether the file system is read-only. | <pre>Returns whether the file system is read-only. | ||
</pre> | </pre> | ||
* | * <code>write(handle:number, value:string):boolean</code> | ||
<pre>Writes the specified data to an open file descriptor with the specified handle. | <pre>Writes the specified data to an open file descriptor with the specified handle. | ||
</pre> | </pre> | ||
* | * <code>spaceTotal():number</code> | ||
<pre>The overall capacity of the file system, in bytes. | <pre>The overall capacity of the file system, in bytes. | ||
</pre> | </pre> | ||
* | * <code>isDirectory(path:string):boolean</code> | ||
<pre>Returns whether the object at the specified absolute path in the file system is a directory. | <pre>Returns whether the object at the specified absolute path in the file system is a directory. | ||
</pre> | </pre> | ||
* | * <code>rename(from:string, to:string):boolean</code> | ||
<pre>Renames/moves an object from the first specified absolute path in the file system to the second. | <pre>Renames/moves an object from the first specified absolute path in the file system to the second. | ||
</pre> | </pre> | ||
* | * <code>list(path:string):table</code> | ||
<pre>Returns a list of names of objects in the directory at the specified absolute path in the file system. | <pre>Returns a list of names of objects in the directory at the specified absolute path in the file system. | ||
</pre> | </pre> | ||
* | * <code>lastModified(path:string):number</code> | ||
<pre>Returns the (real world) timestamp of when the object at the specified absolute path in the file system was modified. | <pre>Returns the (real world) timestamp of when the object at the specified absolute path in the file system was modified. | ||
</pre> | </pre> | ||
* | * <code>getLabel():string</code> | ||
<pre>Get the current label of the file system. | <pre>Get the current label of the file system. | ||
</pre> | </pre> | ||
* | * <code>remove(path:string):boolean</code> | ||
<pre>Removes the object at the specified absolute path in the file system. | <pre>Removes the object at the specified absolute path in the file system. | ||
</pre> | </pre> | ||
* | * <code>close(handle:number)</code> | ||
<pre>Closes an open file descriptor with the specified handle. | <pre>Closes an open file descriptor with the specified handle. | ||
</pre> | </pre> | ||
* | * <code>size(path:string):number</code> | ||
<pre>Returns the size of the object at the specified absolute path in the file system. | <pre>Returns the size of the object at the specified absolute path in the file system. | ||
</pre> | </pre> | ||
* | * <code>read(handle:number, count:number):string or nil</code> | ||
<pre>Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached. | <pre>Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached. | ||
</pre> | </pre> | ||
* | * <code>setLabel(value:string):string</code> | ||
<pre>Sets the label of the file system. Returns the new value, which may be truncated. | <pre>Sets the label of the file system. Returns the new value, which may be truncated. | ||
| Line 81: | Line 81: | ||
{{:Component/contents}} | {{:Component/contents}} | ||
Latest revision as of 20:27, 24 August 2026
Component: Filesystem
This component is provided by Floppy Disks or Hard Disk Drives in Managed mode (for Unmanaged mode, see Drive)
Component name: filesystem. Callbacks:
spaceUsed():number
The currently used capacity of the file system, in bytes.
open(path:string[, mode:string='r']):number
Opens a new file descriptor and returns its handle.
seek(handle:number, whence:string, offset:number):number
Seeks in an open file descriptor with the specified handle. Returns the new pointer position.
makeDirectory(path:string):boolean
Creates a directory at the specified absolute path in the file system. Creates parent directories, if necessary.
exists(path:string):boolean
Returns whether an object exists at the specified absolute path in the file system.
isReadOnly():boolean
Returns whether the file system is read-only.
write(handle:number, value:string):boolean
Writes the specified data to an open file descriptor with the specified handle.
spaceTotal():number
The overall capacity of the file system, in bytes.
isDirectory(path:string):boolean
Returns whether the object at the specified absolute path in the file system is a directory.
rename(from:string, to:string):boolean
Renames/moves an object from the first specified absolute path in the file system to the second.
list(path:string):table
Returns a list of names of objects in the directory at the specified absolute path in the file system.
lastModified(path:string):number
Returns the (real world) timestamp of when the object at the specified absolute path in the file system was modified.
getLabel():string
Get the current label of the file system.
remove(path:string):boolean
Removes the object at the specified absolute path in the file system.
close(handle:number)
Closes an open file descriptor with the specified handle.
size(path:string):number
Returns the size of the object at the specified absolute path in the file system.
read(handle:number, count:number):string or nil
Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.
setLabel(value:string):string
Sets the label of the file system. Returns the new value, which may be truncated.
| Components | |
|---|---|
| Core Components | Access Point - Computer - Drone - Drive - EEPROM - Filesystem - GPU - Microcontroller - Modem - Redstone - Robot - Transposer |
| Others | Component Access - Signals |
| Cross-Mod Integration | Applied Energistics |