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 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<FilePath, FileError>

Returns the current working directory

Source

pub fn get_home_dir() -> Option<FilePath>

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

Source

pub fn get_cache_dir() -> Option<FilePath>

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

Source

pub fn get_config_dir() -> Option<FilePath>

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

Source

pub fn get_config_local_dir() -> Option<FilePath>

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

Source

pub fn get_data_dir() -> Option<FilePath>

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<FilePath>

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<FilePath>

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

Source

pub fn get_document_dir() -> Option<FilePath>

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

Source

pub fn get_download_dir() -> Option<FilePath>

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

Source

pub fn get_executable_dir() -> Option<FilePath>

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

Source

pub fn get_font_dir() -> Option<FilePath>

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

Source

pub fn get_picture_dir() -> Option<FilePath>

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

Source

pub fn get_preference_dir() -> Option<FilePath>

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

Source

pub fn get_public_dir() -> Option<FilePath>

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

Source

pub fn get_runtime_dir() -> Option<FilePath>

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

Source

pub fn get_state_dir() -> Option<FilePath>

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

Source

pub fn get_audio_dir() -> Option<FilePath>

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

Source

pub fn get_video_dir() -> Option<FilePath>

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

Source

pub fn get_template_dir() -> Option<FilePath>

Returns the user’s templates directory

Source

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

Joins this path with another path component

Source

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

Joins this path with a string component

Source

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

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<Void, FileError>

Creates this directory and all parent directories

Source

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

Creates this directory (parent must exist)

Source

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

Removes this file

Source

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

Removes this directory (must be empty)

Source

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

Removes this directory and all contents

Source

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

Reads the entire file at this path as bytes

Source

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

Reads the entire file at this path as a string

Source

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

Writes bytes to the file at this path

Source

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

Writes a string to the file at this path

Source

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

Copies a file from this path to another path

Source

pub fn rename_to(&self, dest: &FilePath) -> Result<Void, FileError>

Renames/moves a file from this path to another path

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

Source

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

Returns metadata about the file/directory

Source

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

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

Trait Implementations§

Source§

impl Clone for FilePath

Source§

fn clone(&self) -> FilePath

Returns a duplicate of the value. Read more
1.0.0 · 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 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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for FilePath

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.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool