pub struct Filesystem(pub Address);Expand description
The filesystem component (18 methods).
Provided by OpenComputers’ FileSystem.
Tuple Fields§
§0: AddressImplementations§
Source§impl Filesystem
impl Filesystem
Sourcepub fn close(&self, handle: Handle) -> Result<()>
pub fn close(&self, handle: Handle) -> Result<()>
Closes an open file descriptor with the specified handle.
Lua: filesystem.close(handle:userdata)
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn close_async(&self, handle: Handle) -> Result<()>
pub async fn close_async(&self, handle: Handle) -> Result<()>
Self::close without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn exists(&self, path: impl AsRef<[u8]>) -> Result<bool>
pub fn exists(&self, path: impl AsRef<[u8]>) -> Result<bool>
Returns whether an object exists at the specified absolute path in the file system.
Lua: filesystem.exists(path:string):boolean
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn exists_async(&self, path: impl AsRef<[u8]>) -> Result<bool>
pub async fn exists_async(&self, path: impl AsRef<[u8]>) -> Result<bool>
Self::exists without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn get_label(&self) -> Result<OcString>
pub fn get_label(&self) -> Result<OcString>
Get the current label of the drive.
Lua: filesystem.getLabel():string
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn get_label_async(&self) -> Result<OcString>
pub async fn get_label_async(&self) -> Result<OcString>
Self::get_label without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn is_directory(&self, path: impl AsRef<[u8]>) -> Result<bool>
pub fn is_directory(&self, path: impl AsRef<[u8]>) -> Result<bool>
Returns whether the object at the specified absolute path in the file system is a directory.
Lua: filesystem.isDirectory(path:string):boolean
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn is_directory_async(&self, path: impl AsRef<[u8]>) -> Result<bool>
pub async fn is_directory_async(&self, path: impl AsRef<[u8]>) -> Result<bool>
Self::is_directory without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn is_read_only(&self) -> Result<bool>
pub fn is_read_only(&self) -> Result<bool>
Returns whether the file system is read-only.
Lua: filesystem.isReadOnly():boolean
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn is_read_only_async(&self) -> Result<bool>
pub async fn is_read_only_async(&self) -> Result<bool>
Self::is_read_only without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn last_modified(&self, path: impl AsRef<[u8]>) -> Result<Number>
pub fn last_modified(&self, path: impl AsRef<[u8]>) -> Result<Number>
Returns the (real world) timestamp of when the object at the specified absolute path in the file system was modified.
Lua: filesystem.lastModified(path:string):number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn last_modified_async(
&self,
path: impl AsRef<[u8]>,
) -> Result<Number>
pub async fn last_modified_async( &self, path: impl AsRef<[u8]>, ) -> Result<Number>
Self::last_modified without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn list(&self, path: impl AsRef<[u8]>) -> Result<Value>
pub fn list(&self, path: impl AsRef<[u8]>) -> Result<Value>
Returns a list of names of objects in the directory at the specified absolute path in the file system.
Lua: filesystem.list(path:string):table
Indirect call: waits for the next server tick.
Sourcepub async fn list_async(&self, path: impl AsRef<[u8]>) -> Result<Value>
pub async fn list_async(&self, path: impl AsRef<[u8]>) -> Result<Value>
Self::list without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn make_directory(&self, path: impl AsRef<[u8]>) -> Result<bool>
pub fn make_directory(&self, path: impl AsRef<[u8]>) -> Result<bool>
Creates a directory at the specified absolute path in the file system. Creates parent directories, if necessary.
Lua: filesystem.makeDirectory(path:string):boolean
Indirect call: waits for the next server tick.
Sourcepub async fn make_directory_async(&self, path: impl AsRef<[u8]>) -> Result<bool>
pub async fn make_directory_async(&self, path: impl AsRef<[u8]>) -> Result<bool>
Self::make_directory without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn open(&self, path: impl AsRef<[u8]>, mode: Option<&str>) -> Result<Handle>
pub fn open(&self, path: impl AsRef<[u8]>, mode: Option<&str>) -> Result<Handle>
Opens a new file descriptor and returns its handle.
Lua: filesystem.open(path:string[, mode:string='r']):userdata
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 4).
mode defaults to 'r'.
Sourcepub async fn open_async(
&self,
path: impl AsRef<[u8]>,
mode: Option<&str>,
) -> Result<Handle>
pub async fn open_async( &self, path: impl AsRef<[u8]>, mode: Option<&str>, ) -> Result<Handle>
Self::open without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn read(
&self,
handle: Handle,
count: impl Into<Number>,
) -> Result<Option<OcString>>
pub fn read( &self, handle: Handle, count: impl Into<Number>, ) -> Result<Option<OcString>>
Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.
Lua: filesystem.read(handle:userdata, count:number):string or nil
Direct call (runs immediately, drawing on the per-tick budget; OC’s limit 15).
Sourcepub async fn read_async(
&self,
handle: Handle,
count: impl Into<Number>,
) -> Result<Option<OcString>>
pub async fn read_async( &self, handle: Handle, count: impl Into<Number>, ) -> Result<Option<OcString>>
Self::read without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn remove(&self, path: impl AsRef<[u8]>) -> Result<bool>
pub fn remove(&self, path: impl AsRef<[u8]>) -> Result<bool>
Removes the object at the specified absolute path in the file system.
Lua: filesystem.remove(path:string):boolean
Indirect call: waits for the next server tick.
Sourcepub async fn remove_async(&self, path: impl AsRef<[u8]>) -> Result<bool>
pub async fn remove_async(&self, path: impl AsRef<[u8]>) -> Result<bool>
Self::remove without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn rename(
&self,
from: impl AsRef<[u8]>,
to: impl AsRef<[u8]>,
) -> Result<bool>
pub fn rename( &self, from: impl AsRef<[u8]>, to: impl AsRef<[u8]>, ) -> Result<bool>
Renames/moves an object from the first specified absolute path in the file system to the second.
Lua: filesystem.rename(from:string, to:string):boolean
Indirect call: waits for the next server tick.
Sourcepub async fn rename_async(
&self,
from: impl AsRef<[u8]>,
to: impl AsRef<[u8]>,
) -> Result<bool>
pub async fn rename_async( &self, from: impl AsRef<[u8]>, to: impl AsRef<[u8]>, ) -> Result<bool>
Self::rename without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn seek(
&self,
handle: Handle,
whence: impl AsRef<[u8]>,
offset: impl Into<Number>,
) -> Result<Number>
pub fn seek( &self, handle: Handle, whence: impl AsRef<[u8]>, offset: impl Into<Number>, ) -> Result<Number>
Seeks in an open file descriptor with the specified handle. Returns the new pointer position.
Lua: filesystem.seek(handle:userdata, whence:string, offset:number):number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn seek_async(
&self,
handle: Handle,
whence: impl AsRef<[u8]>,
offset: impl Into<Number>,
) -> Result<Number>
pub async fn seek_async( &self, handle: Handle, whence: impl AsRef<[u8]>, offset: impl Into<Number>, ) -> Result<Number>
Self::seek without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn set_label(&self, value: impl AsRef<[u8]>) -> Result<OcString>
pub fn set_label(&self, value: impl AsRef<[u8]>) -> Result<OcString>
Sets the label of the drive. Returns the new value, which may be truncated.
Lua: filesystem.setLabel(value:string):string
Indirect call: waits for the next server tick.
Sourcepub async fn set_label_async(&self, value: impl AsRef<[u8]>) -> Result<OcString>
pub async fn set_label_async(&self, value: impl AsRef<[u8]>) -> Result<OcString>
Self::set_label without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn size(&self, path: impl AsRef<[u8]>) -> Result<Number>
pub fn size(&self, path: impl AsRef<[u8]>) -> Result<Number>
Returns the size of the object at the specified absolute path in the file system.
Lua: filesystem.size(path:string):number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn size_async(&self, path: impl AsRef<[u8]>) -> Result<Number>
pub async fn size_async(&self, path: impl AsRef<[u8]>) -> Result<Number>
Self::size without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn space_total(&self) -> Result<Number>
pub fn space_total(&self) -> Result<Number>
The overall capacity of the file system, in bytes.
Lua: filesystem.spaceTotal():number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn space_total_async(&self) -> Result<Number>
pub async fn space_total_async(&self) -> Result<Number>
Self::space_total without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn space_used(&self) -> Result<Number>
pub fn space_used(&self) -> Result<Number>
The currently used capacity of the file system, in bytes.
Lua: filesystem.spaceUsed():number
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn space_used_async(&self) -> Result<Number>
pub async fn space_used_async(&self) -> Result<Number>
Self::space_used without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Sourcepub fn write(&self, handle: Handle, value: impl AsRef<[u8]>) -> Result<bool>
pub fn write(&self, handle: Handle, value: impl AsRef<[u8]>) -> Result<bool>
Writes the specified data to an open file descriptor with the specified handle.
Lua: filesystem.write(handle:userdata, value:string):boolean
Direct call (runs immediately, drawing on the per-tick budget).
Sourcepub async fn write_async(
&self,
handle: Handle,
value: impl AsRef<[u8]>,
) -> Result<bool>
pub async fn write_async( &self, handle: Handle, value: impl AsRef<[u8]>, ) -> Result<bool>
Self::write without blocking: the call is queued, and
the program keeps running until the result comes back; see crate::task.
Trait Implementations§
Source§impl Clone for Filesystem
impl Clone for Filesystem
Source§impl Component for Filesystem
impl Component for Filesystem
Source§fn from_address(address: Address) -> Self
fn from_address(address: Address) -> Self
fn address(&self) -> &Address
Source§fn at(address: impl Into<Address>) -> Option<Self>
fn at(address: impl Into<Address>) -> Option<Self>
address, if it is of this type.Source§fn invoke(&self, method: &str, args: Vec<Value>) -> Result<Vec<Value>>
fn invoke(&self, method: &str, args: Vec<Value>) -> Result<Vec<Value>>
Source§fn invoke_async(&self, method: &str, args: Vec<Value>) -> Call ⓘ
fn invoke_async(&self, method: &str, args: Vec<Value>) -> Call ⓘ
Component::invoke without blocking; see invoke_async.