pub struct FileSystem { /* private fields */ }
Expand description
A FAT16, virtual filesystem.
FAT-16 IS NOT case sensitive. All the paths will be silently converted to uppercase, as in any FAT system. It’s a TODO to support ext4.
Implementations§
Source§impl FileSystem
impl FileSystem
Sourcepub fn new(size: usize) -> Result<Self>
pub fn new(size: usize) -> Result<Self>
Creates a new filesystem with the provided partition size.
The memory buffer of the filesystem is lazy loaded; that is, it will allocate bytes as they are consumed.
Sourcepub fn try_to_bytes(&self) -> Result<Vec<u8>>
pub fn try_to_bytes(&self) -> Result<Vec<u8>>
Serializes the structure into bytes.
Sourcepub fn try_from_bytes(bytes: &[u8]) -> Result<Self>
pub fn try_from_bytes(bytes: &[u8]) -> Result<Self>
Deserializes the structure from bytes.
Sourcepub fn try_to_raw_device(&self) -> Result<Vec<u8>>
pub fn try_to_raw_device(&self) -> Result<Vec<u8>>
Serializes the raw device (MBR + FAT16) into bytes.
Note: this is a compatible filesystem that can be mounted elsewhere.
Sourcepub fn from_raw_device_unchecked(device: Vec<u8>) -> Self
pub fn from_raw_device_unchecked(device: Vec<u8>) -> Self
Deserializes the raw device (MBR + FAT16) from bytes.
Sourcepub fn cwd(&self) -> &RelativePath
pub fn cwd(&self) -> &RelativePath
Returns the current work directory.
Sourcepub fn cd<P: AsRef<RelativePath>>(&mut self, dir: P) -> Result<()>
pub fn cd<P: AsRef<RelativePath>>(&mut self, dir: P) -> Result<()>
Navigates into the provided directory.
Sourcepub fn ls<P: AsRef<RelativePath>>(&self, path: P) -> Result<Vec<DirOrFile>>
pub fn ls<P: AsRef<RelativePath>>(&self, path: P) -> Result<Vec<DirOrFile>>
List the contents of the path.
Sourcepub fn mkdir<P: AsRef<RelativePath>>(&mut self, dir: P) -> Result<()>
pub fn mkdir<P: AsRef<RelativePath>>(&mut self, dir: P) -> Result<()>
Creates the provided path recursively from the current directory.
Sourcepub fn rm<P: AsRef<RelativePath>>(&mut self, path: P) -> Result<()>
pub fn rm<P: AsRef<RelativePath>>(&mut self, path: P) -> Result<()>
Removes a file or an empty directory.