Skip to main content

FileSystem

Struct FileSystem 

Source
pub struct FileSystem<P: PackFile> { /* private fields */ }
Expand description

Core FileSystem representation holding physical directories and loaded pack files.

Implementations§

Source§

impl<P: PackFile> FileSystem<P>

Source

pub fn load_from_path<G: GameInfoProvider>( game_path: &Path, options: &FileSystemOptions, ) -> Result<Self, FileSystemError>

Loads the filesystem from a specific game directory (where gameinfo.txt resides).

Source

pub fn root_path(&self) -> &PathBuf

Source

pub fn search_path_dirs(&self) -> &HashMap<String, Vec<PathBuf>>

Source

pub fn search_path_dirs_mut(&mut self) -> &mut HashMap<String, Vec<PathBuf>>

Source

pub fn search_path_vpks(&self) -> &HashMap<String, Vec<Arc<P>>>

Source

pub fn search_path_vpks_mut(&mut self) -> &mut HashMap<String, Vec<Arc<P>>>

Source

pub fn find_file(&self, file_path: &str, search_path: &str) -> Option<PathBuf>

Source

pub fn read( &self, file_path: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<Vec<u8>>

Reads data from the internal mounted paths using standard Source Engine priorities.

Source

pub fn read_for_map( &self, map_pack: Option<&P>, file_path: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<Vec<u8>>

Same as read, but takes an optional active map pack file which gets highest priority.

Source

pub fn read_str( &self, file_path: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<String>

Source

pub fn find_asset( &self, name: &str, prefix: &str, suffix: &str, search_path: &str, ) -> Option<PathBuf>

Finds an asset’s PathBuf without reading its contents into memory.

Source

pub fn read_asset( &self, name: &str, prefix: &str, suffix: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<Vec<u8>>

Reads any asset as raw bytes, safely appending prefix and suffix if missing.

Source

pub fn read_asset_str( &self, name: &str, prefix: &str, suffix: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<String>

Reads any asset as a UTF-8 string, safely appending prefix and suffix if missing.

Source

pub fn read_material( &self, name: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<Vec<u8>>

Reads a material file (.vmt).

Source

pub fn read_material_str( &self, name: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<String>

Reads a material file (.vmt) as a UTF-8 string.

Source

pub fn read_model( &self, name: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<Vec<u8>>

Reads a model file (.mdl).

Source

pub fn read_model_str( &self, name: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<String>

Reads a model file (.mdl) as a UTF-8 string.

Source

pub fn read_sound_str( &self, name: &str, search_path: &str, prioritize_vpks: bool, ) -> Option<String>

Reads a sound file (.wav or fallback to .mp3) as a UTF-8 string.

Trait Implementations§

Source§

impl<P: PackFile> Clone for FileSystem<P>

Source§

fn clone(&self) -> Self

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<P: Debug + PackFile> Debug for FileSystem<P>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P> Freeze for FileSystem<P>

§

impl<P> RefUnwindSafe for FileSystem<P>
where P: RefUnwindSafe,

§

impl<P> Send for FileSystem<P>
where P: Sync + Send,

§

impl<P> Sync for FileSystem<P>
where P: Sync + Send,

§

impl<P> Unpin for FileSystem<P>

§

impl<P> UnsafeUnpin for FileSystem<P>

§

impl<P> UnwindSafe for FileSystem<P>
where P: RefUnwindSafe,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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