pub struct ResFilesystem { /* private fields */ }Expand description
A virtual read-only filesystem you can use to walk through the game’s resources. This filesystem is designed to work really fast on systems where it will run for a long time and take advantage of its internal cache, but it will also work on run-once environment such as CLI where the first answer latency must be minimal.
This filesystem is made to be shared between threads and immutably accessed.
Internally, this filesystem has a cache to improve response delay. The challenge is that directories may reside in many packages, but files are present only in one package.
Implementations§
Source§impl ResFilesystem
impl ResFilesystem
Sourcepub fn new<P: Into<PathBuf>>(dir_path: P) -> Result<Self>
pub fn new<P: Into<PathBuf>>(dir_path: P) -> Result<Self>
Create a new resources filesystem with the given options. This function is blocking while it is doing a rudimentary early indexing, so this may take some time.
Sourcepub fn read<P: AsRef<str>>(&self, file_path: P) -> Result<ResReadFile>
pub fn read<P: AsRef<str>>(&self, file_path: P) -> Result<ResReadFile>
Read a file from its path in the resource filesystem.
Sourcepub fn read_dir<P: AsRef<str>>(&self, dir_path: P) -> Result<ResReadDir>
pub fn read_dir<P: AsRef<str>>(&self, dir_path: P) -> Result<ResReadDir>
Read a directory’s entries in the resource filesystem. This function may be blocking a short time because it needs to find the first node of that directory.
This function may return a file not found error if no package contains this directory.
Trait Implementations§
Source§impl Clone for ResFilesystem
impl Clone for ResFilesystem
Source§fn clone(&self) -> ResFilesystem
fn clone(&self) -> ResFilesystem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more