pub struct FilePath { /* private fields */ }
Expand description
A file path.
Implementations§
Source§impl FilePath
Storage Path
impl FilePath
Storage Path
Sourcepub fn path(&self) -> &StoragePath
pub fn path(&self) -> &StoragePath
Gets the storage path.
Sourcepub fn to_path(self) -> StoragePath
pub fn to_path(self) -> StoragePath
Converts the file path to a storage path.
Source§impl FilePath
Is System
impl FilePath
Is System
Sourcepub fn is_local_path(&self) -> bool
pub fn is_local_path(&self) -> bool
Checks if the path is a local path.
Sourcepub fn is_unix_path(&self) -> bool
pub fn is_unix_path(&self) -> bool
Checks if the path is a Unix path.
Sourcepub fn is_windows_path(&self) -> bool
pub fn is_windows_path(&self) -> bool
Checks if the path is a Windows path.
Source§impl FilePath
Clone
impl FilePath
Clone
Sourcepub fn clone_with_extra_capacity(&self, extra_capacity: usize) -> Self
pub fn clone_with_extra_capacity(&self, extra_capacity: usize) -> Self
Clones the path with the extra capacity.
Source§impl FilePath
Append
impl FilePath
Append
Sourcepub fn with_appended<S>(self, s: S) -> StoragePath
pub fn with_appended<S>(self, s: S) -> StoragePath
Appends the string.
Sourcepub fn clone_append<S>(&self, s: S) -> StoragePath
pub fn clone_append<S>(&self, s: S) -> StoragePath
Clones the path and appends the string.
The result is the same as path.clone().with_appended(s)
but minimizes allocation.
Source§impl FilePath
Append Char
impl FilePath
Append Char
Sourcepub fn with_appended_char(self, c: char) -> StoragePath
pub fn with_appended_char(self, c: char) -> StoragePath
Appends the char.
Source§impl FilePath
Make Folder
impl FilePath
Make Folder
Sourcepub fn make_folder(self) -> FolderPath
pub fn make_folder(self) -> FolderPath
Makes the file a folder by appending a file separator.
Source§impl FilePath
Delete If Exists
impl FilePath
Delete If Exists
Sourcepub fn delete_if_exists(&self) -> Result<bool, Error>
pub fn delete_if_exists(&self) -> Result<bool, Error>
Deletes the file if it exists.
Returns Ok(true)
if the file existed and was deleted.
Returns Ok(false)
if the file did not exist.
Source§impl FilePath
Read as String
impl FilePath
Read as String
Sourcepub fn read_as_string(&self) -> Result<String, Error>
pub fn read_as_string(&self) -> Result<String, Error>
Reads the file as a String
.
Returns Ok(file_content)
.
Returns Err(FileNotFound)
if the file did not exist.
Source§impl FilePath
Write Empty
impl FilePath
Write Empty
Sourcepub fn write_empty(&self) -> Result<(), Error>
pub fn write_empty(&self) -> Result<(), Error>
Writes an empty file.
Returns Ok(())
.
Returns Err(FileAlreadyExists)
if the file already exists.
Source§impl FilePath
Write Empty If-Not-Exists
impl FilePath
Write Empty If-Not-Exists
Sourcepub fn write_empty_if_not_exists(&self) -> Result<bool, Error>
pub fn write_empty_if_not_exists(&self) -> Result<bool, Error>
Writes an empty file if the file does not exist.
Returns Ok(true)
if the file was written.
Returns Ok(false)
if the file already existed.