Skip to main content

FilePath

Struct FilePath 

Source
#[repr(C)]
pub struct FilePath { pub inner: AzString, }
Expand description

FFI-safe path type with OOP-style methods

This wraps a string path and provides method-based access to file operations.

Fields§

§inner: AzString

Implementations§

Source§

impl FilePath

Source

pub const fn new(path: AzString) -> Self

Creates a new path from a string

Source

pub fn empty() -> Self

Creates an empty path

Source

pub fn from_str(s: &str) -> Self

Creates a path from a string slice

Source

pub fn get_temp_dir() -> Self

Returns the system temporary directory

Source

pub fn get_current_dir() -> Result<Self, FileError>

Returns the current working directory

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn get_home_dir() -> Option<Self>

Returns the user’s home directory (e.g., /home/username on Linux, C:\Users\username on Windows)

Source

pub fn get_cache_dir() -> Option<Self>

Returns the user’s cache directory (e.g., ~/.cache on Linux, ~/Library/Caches on macOS)

Source

pub fn get_config_dir() -> Option<Self>

Returns the user’s config directory (e.g., ~/.config on Linux, ~/Library/Application Support on macOS)

Source

pub fn get_config_local_dir() -> Option<Self>

Returns the user’s local config directory (e.g., ~/.config on Linux, ~/Library/Application Support on macOS)

Source

pub fn get_data_dir() -> Option<Self>

Returns the user’s data directory (e.g., ~/.local/share on Linux, ~/Library/Application Support on macOS)

Source

pub fn get_data_local_dir() -> Option<Self>

Returns the user’s local data directory (e.g., ~/.local/share on Linux, ~/Library/Application Support on macOS)

Source

pub fn get_desktop_dir() -> Option<Self>

Returns the user’s desktop directory (e.g., ~/Desktop)

Source

pub fn get_document_dir() -> Option<Self>

Returns the user’s documents directory (e.g., ~/Documents)

Source

pub fn get_download_dir() -> Option<Self>

Returns the user’s downloads directory (e.g., ~/Downloads)

Source

pub fn get_executable_dir() -> Option<Self>

Returns the user’s executable directory (e.g., ~/.local/bin on Linux)

Source

pub fn get_font_dir() -> Option<Self>

Returns the user’s font directory (e.g., ~/.local/share/fonts on Linux, ~/Library/Fonts on macOS)

Source

pub fn get_picture_dir() -> Option<Self>

Returns the user’s pictures directory (e.g., ~/Pictures)

Source

pub fn get_preference_dir() -> Option<Self>

Returns the user’s preference directory (e.g., ~/.config on Linux, ~/Library/Preferences on macOS)

Source

pub fn get_public_dir() -> Option<Self>

Returns the user’s public directory (e.g., ~/Public)

Source

pub fn get_runtime_dir() -> Option<Self>

Returns the user’s runtime directory (e.g., /run/user/1000 on Linux)

Source

pub fn get_state_dir() -> Option<Self>

Returns the user’s state directory (e.g., ~/.local/state on Linux)

Source

pub fn get_audio_dir() -> Option<Self>

Returns the user’s audio directory (e.g., ~/Music)

Source

pub fn get_video_dir() -> Option<Self>

Returns the user’s video directory (e.g., ~/Videos)

Source

pub fn get_template_dir() -> Option<Self>

Returns the user’s templates directory

Source

pub fn join(&self, other: &Self) -> Self

Joins this path with another path component

Source

pub fn join_str(&self, component: &AzString) -> Self

Joins this path with a string component

Source

pub fn parent(&self) -> Option<Self>

Returns the parent directory of this path

Source

pub fn file_name(&self) -> Option<AzString>

Returns the file name component of this path

Source

pub fn extension(&self) -> Option<AzString>

Returns the file extension of this path

Source

pub fn exists(&self) -> bool

Checks if the path exists on the filesystem

Source

pub fn is_file(&self) -> bool

Checks if the path is a file

Source

pub fn is_dir(&self) -> bool

Checks if the path is a directory

Source

pub fn is_absolute(&self) -> bool

Checks if the path is absolute

Source

pub fn create_dir_all(&self) -> Result<EmptyStruct, FileError>

Creates this directory and all parent directories

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn create_dir(&self) -> Result<EmptyStruct, FileError>

Creates this directory (parent must exist)

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn remove_file(&self) -> Result<EmptyStruct, FileError>

Removes this file

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn remove_dir(&self) -> Result<EmptyStruct, FileError>

Removes this directory (must be empty)

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn remove_dir_all(&self) -> Result<EmptyStruct, FileError>

Removes this directory and all contents

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn read_bytes(&self) -> Result<U8Vec, FileError>

Reads the entire file at this path as bytes

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn read_string(&self) -> Result<AzString, FileError>

Reads the entire file at this path as a string

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn write_bytes(&self, data: &U8Vec) -> Result<EmptyStruct, FileError>

Writes bytes to the file at this path

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn write_string(&self, data: &AzString) -> Result<EmptyStruct, FileError>

Writes a string to the file at this path

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn copy_to(&self, dest: &Self) -> Result<u64, FileError>

Copies a file from this path to another path

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn rename_to(&self, dest: &Self) -> Result<EmptyStruct, FileError>

Renames/moves a file from this path to another path

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn as_str(&self) -> &str

Returns the path as a string reference

Source

pub fn as_string(&self) -> AzString

Returns the path as an AzString

Source

pub fn read_dir(&self) -> Result<DirEntryVec, FileError>

Lists directory contents

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn metadata(&self) -> Result<FileMetadata, FileError>

Returns metadata about the file/directory

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Source

pub fn canonicalize(&self) -> Result<Self, FileError>

Makes the path canonical (absolute, with no . or .. components)

§Errors

Returns a FileError if the filesystem operation fails (e.g. path not found, permission denied, or an I/O error).

Trait Implementations§

Source§

impl Clone for FilePath

Source§

fn clone(&self) -> FilePath

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FilePath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FilePath

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for FilePath

Source§

impl From<&str> for FilePath

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<AzString> for FilePath

Source§

fn from(s: AzString) -> Self

Converts to this type from the input type.
Source§

impl From<String> for FilePath

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for FilePath

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for FilePath

Source§

fn eq(&self, other: &FilePath) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FilePath

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetHash for T
where T: Hash,

Source§

fn get_hash(&self) -> u64

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.