ds_rom::rom

Struct FileSystem

Source
pub struct FileSystem<'a> { /* private fields */ }
Expand description

Contains files and directories to be placed into a ROM.

Implementations§

Source§

impl<'a> FileSystem<'a>

Source

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.

Source

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.

Source

pub fn is_dir(id: u16) -> bool

Returns whether the ID is a directory ID.

Source

pub fn is_file(id: u16) -> bool

Returns whether the ID is a file ID.

Source

pub fn name(&self, id: u16) -> &str

Returns the name of a directory or file.

Source

pub fn dir(&self, id: u16) -> &Dir

Returns a directory.

Source

pub fn file(&self, id: u16) -> &File<'_>

Returns a file.

Source

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.

Source

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.

Source

pub fn sort_for_fnt(&mut self)

Sorts the entire FileSystem so that it’s laid out in the right order for the FNT.

Source

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.

Source

pub fn traverse_files<I, Cb>(&self, path_order: I, callback: Cb)
where I: IntoIterator<Item = &'a str>, Cb: FnMut(&File<'_>, &Path),

Traverses the FileSystem and calls callback for each file found. The directories will be prioritized according to the path_order.

Source

pub fn max_file_id(&self) -> u16

Returns the max file ID of this FileSystem.

Source

pub fn display(&self, indent: usize) -> DisplayFileSystem<'_>

Creates a DisplayFileSystem which implements Display.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for FileSystem<'a>

§

impl<'a> RefUnwindSafe for FileSystem<'a>

§

impl<'a> Send for FileSystem<'a>

§

impl<'a> Sync for FileSystem<'a>

§

impl<'a> Unpin for FileSystem<'a>

§

impl<'a> UnwindSafe for FileSystem<'a>

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