pub struct FileSystem<'a> { /* private fields */ }Expand description
Contains files and directories to be placed into a ROM.
Implementations§
source§impl<'a> FileSystem<'a>
impl<'a> FileSystem<'a>
sourcepub fn new(num_overlays: usize) -> Self
pub fn new(num_overlays: usize) -> Self
Creates a new FileSystem. The number of overlays are used to determine the first file ID, since overlays are also
located in the FAT but not the FNT.
sourcepub fn load<P: AsRef<Path>>(
root: P,
num_overlays: usize,
) -> Result<Self, FileError>
pub fn load<P: AsRef<Path>>( root: P, num_overlays: usize, ) -> Result<Self, FileError>
Loads a file system from the given root directory. This will traverse and add all folders and files into the
FileSystem struct.
§Errors
This function will return an error if an I/O operation fails.
sourcepub fn parse(
fnt: &Fnt<'_>,
fat: &[FileAlloc],
rom: &'a Rom<'_>,
) -> Result<Self, FileParseError>
pub fn parse( fnt: &Fnt<'_>, fat: &[FileAlloc], rom: &'a Rom<'_>, ) -> Result<Self, FileParseError>
Parses an FNT, FAT and ROM to create a FileSystem.
§Errors
This function will return an error if raw::Rom::num_arm9_overlays or raw::Rom::num_arm7_overlays fails, or if
a file or directory ID is missing from the FNT.
sourcepub fn build_fnt(&self) -> Result<Fnt<'_>, FileBuildError>
pub fn build_fnt(&self) -> Result<Fnt<'_>, FileBuildError>
Builds an FNT from this FileSystem.
§Errors
This function will return an error if a file/directory name contains non-ASCII characters.
sourcepub fn sort_for_fnt(&mut self)
pub fn sort_for_fnt(&mut self)
Sorts the entire FileSystem so that it’s laid out in the right order for the FNT.
sourcepub fn sort_for_rom(&mut self)
pub fn sort_for_rom(&mut self)
Sorts the entire FileSystem so that files laid out in the right order for appending to the ROM.
sourcepub fn traverse_files<I, Cb>(&self, path_order: I, callback: Cb)
pub fn traverse_files<I, Cb>(&self, path_order: I, callback: Cb)
Traverses the FileSystem and calls callback for each file found. The directories will be prioritized according to
the path_order.
sourcepub fn max_file_id(&self) -> u16
pub fn max_file_id(&self) -> u16
Returns the max file ID of this FileSystem.
sourcepub fn display(&self, indent: usize) -> DisplayFileSystem<'_>
pub fn display(&self, indent: usize) -> DisplayFileSystem<'_>
Creates a DisplayFileSystem which implements Display.
sourcepub fn compute_path_order(&self) -> Vec<String>
pub fn compute_path_order(&self) -> Vec<String>
Computes the path order that the FileSystem is currently in. This can be saved and reused in
Self::traverse_files to traverse in the same order later.