Struct rialight_filesystem::File
source · pub struct File { /* private fields */ }
Expand description
Represents a path to a file or directory.
Constructing a File
object
File
can be constructed either with a path or a
URL. The following URL schemes are supported:
file:
app:
file in the application installation directoryapp-storage:
file in the application private directory
The File
constructor performs implicit normalization of the
given path argument.
Implementations
sourceimpl File
impl File
sourcepub fn name_without_suffix<S: AsRef<str>>(&self, suffix: S) -> String
pub fn name_without_suffix<S: AsRef<str>>(&self, suffix: S) -> String
The last portion of this path, excluding the given suffix.
sourcepub fn application_directory() -> Self
pub fn application_directory() -> Self
Returns a reference to the application installation directory.
This is equivalent to the URL app://
.
sourcepub fn application_storage_directory() -> Self
pub fn application_storage_directory() -> Self
Returns a reference to the application private directory.
This is equivalent to the URL app-storage://
.
sourcepub fn native_path(&self) -> String
pub fn native_path(&self) -> String
The full path in the host operating system representation.
sourcepub fn resolve_path<S: AsRef<str>>(&self, arg: S) -> Self
pub fn resolve_path<S: AsRef<str>>(&self, arg: S) -> Self
Resolves relative path.
sourcepub fn relative_path(&self, another: &File) -> String
pub fn relative_path(&self, another: &File) -> String
Relative path from the File
object to another File
object.
sourcepub fn downloads_directory() -> Option<File>
pub fn downloads_directory() -> Option<File>
The user downloads directory.
sourcepub fn documents_directory() -> Option<File>
pub fn documents_directory() -> Option<File>
The user documents directory.
sourcepub fn executable_directory() -> Option<File>
pub fn executable_directory() -> Option<File>
The executable directory.
pub fn user_directory() -> Option<File>
sourcepub fn pictures_directory() -> Option<File>
pub fn pictures_directory() -> Option<File>
The user pictures directory.
sourcepub fn videos_directory() -> Option<File>
pub fn videos_directory() -> Option<File>
The user videos directory.
sourcepub fn working_directory() -> Option<File>
pub fn working_directory() -> Option<File>
The application’s working directory (used primarily for command-line applications).
sourcepub fn application_based_native_path(&self) -> PathBuf
pub fn application_based_native_path(&self) -> PathBuf
Native path of the File
object. If the File
object
was constructed from app:
or app-storage:
scheme,
then its path is resolved to the internal application directory.
sourcepub fn is_directory(&self) -> bool
pub fn is_directory(&self) -> bool
Determines whether the referenced path is a directory.
sourcepub fn is_symbolic_link(&self) -> bool
pub fn is_symbolic_link(&self) -> bool
Determines whether the referenced path is a symbolic link.
sourcepub fn parent(&self) -> Option<File>
pub fn parent(&self) -> Option<File>
The directory that contains the file or directory referenced by the File
object.
This property is identical to the return value of resolve_path("..")
except that the parent of a root directory is None
.
sourcepub fn canonicalize(&self) -> File
pub fn canonicalize(&self) -> File
Returns a canonicalization of the File
path.
sourcepub async fn canonicalize_async(&self) -> File
pub async fn canonicalize_async(&self) -> File
Returns a canonicalization of the File
path.
sourcepub fn copy_to(&self, new_location: &File) -> Result<(), IoError>
pub fn copy_to(&self, new_location: &File) -> Result<(), IoError>
Copies the file at the location specified by the File
object to the location specified by the new_location
parameter.
This method will overwrite the contents of new_location
.
sourcepub async fn copy_to_async(&self, new_location: &File) -> Result<(), IoError>
pub async fn copy_to_async(&self, new_location: &File) -> Result<(), IoError>
Copies the file at the location specified by the File
object to the location specified by the new_location
parameter.
This method will overwrite the contents of new_location
.
sourcepub fn create_directory(&self) -> Result<(), IoError>
pub fn create_directory(&self) -> Result<(), IoError>
Creates the specified directory and any necessary parent directories. If the directory already exists, no action is taken.
sourcepub async fn create_directory_async(&self) -> Result<(), IoError>
pub async fn create_directory_async(&self) -> Result<(), IoError>
Creates the specified directory and any necessary parent directories. If the directory already exists, no action is taken.
sourcepub async fn read_utf8_async(&self) -> Result<String, IoError>
pub async fn read_utf8_async(&self) -> Result<String, IoError>
Read file contents as UTF-8 string.
sourcepub fn get_directory_listing(&self) -> Result<Vec<File>, IoError>
pub fn get_directory_listing(&self) -> Result<Vec<File>, IoError>
Returns a vector of File
objects corresponding to files and directories
in the directory represented by the File
object.
sourcepub fn delete_empty_directory(&self) -> Result<(), IoError>
pub fn delete_empty_directory(&self) -> Result<(), IoError>
Deletes empty directory.
sourcepub async fn delete_empty_directory_async(&self) -> Result<(), IoError>
pub async fn delete_empty_directory_async(&self) -> Result<(), IoError>
Deletes empty directory.
sourcepub fn delete_all_directory(&self) -> Result<(), IoError>
pub fn delete_all_directory(&self) -> Result<(), IoError>
Deletes directory after deleting all its contents.
sourcepub async fn delete_all_directory_async(&self) -> Result<(), IoError>
pub async fn delete_all_directory_async(&self) -> Result<(), IoError>
Deletes directory after deleting all its contents.
sourcepub fn delete_file(&self) -> Result<(), IoError>
pub fn delete_file(&self) -> Result<(), IoError>
Deletes file.
sourcepub async fn delete_file_async(&self) -> Result<(), IoError>
pub async fn delete_file_async(&self) -> Result<(), IoError>
Deletes file.
sourcepub fn rename(&self, to: &File) -> Result<(), IoError>
pub fn rename(&self, to: &File) -> Result<(), IoError>
Rename a file or directory to a new name specified by the to
parameter,
replacing the original file if to already exists.
sourcepub async fn rename_async(&self, to: &File) -> Result<(), IoError>
pub async fn rename_async(&self, to: &File) -> Result<(), IoError>
Rename a file or directory to a new name specified by the to
parameter,
replacing the original file if to already exists.
sourcepub async fn write_async<B: AsRef<[u8]>>(&self, b: B) -> Result<(), IoError>
pub async fn write_async<B: AsRef<[u8]>>(&self, b: B) -> Result<(), IoError>
Writes bytes to a file.
sourcepub fn creation_date(&self) -> Result<SystemTime, IoError>
pub fn creation_date(&self) -> Result<SystemTime, IoError>
Creation date.
sourcepub async fn creation_date_async(&self) -> Result<SystemTime, IoError>
pub async fn creation_date_async(&self) -> Result<SystemTime, IoError>
Creation date.
sourcepub fn modification_date(&self) -> Result<SystemTime, IoError>
pub fn modification_date(&self) -> Result<SystemTime, IoError>
Modification date.
sourcepub async fn modification_date_async(&self) -> Result<SystemTime, IoError>
pub async fn modification_date_async(&self) -> Result<SystemTime, IoError>
Modification date.
sourcepub async fn size_async(&self) -> Result<i64, IoError>
pub async fn size_async(&self) -> Result<i64, IoError>
Size of the file in bytes.