Initial xenia-rs
This commit is contained in:
40
xenia-rs/crates/xenia-vfs/src/disc_image.rs
Normal file
40
xenia-rs/crates/xenia-vfs/src/disc_image.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
use crate::{VfsDevice, VfsEntry, VfsError};
|
||||
|
||||
/// XISO disc image device. Parses Xbox 360 disc images.
|
||||
pub struct DiscImageDevice {
|
||||
name: String,
|
||||
_data: Vec<u8>,
|
||||
}
|
||||
|
||||
/// XISO sector size
|
||||
pub const SECTOR_SIZE: usize = 0x800;
|
||||
|
||||
impl DiscImageDevice {
|
||||
pub fn open(name: impl Into<String>, path: &std::path::Path) -> Result<Self, VfsError> {
|
||||
let data = std::fs::read(path)?;
|
||||
// TODO: validate XISO header
|
||||
Ok(Self {
|
||||
name: name.into(),
|
||||
_data: data,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl VfsDevice for DiscImageDevice {
|
||||
fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
||||
fn list_root(&self) -> Result<Vec<VfsEntry>, VfsError> {
|
||||
// TODO: Parse XISO directory tree
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
fn read_file(&self, _path: &str) -> Result<Vec<u8>, VfsError> {
|
||||
Err(VfsError::NotFound("Not yet implemented".into()))
|
||||
}
|
||||
|
||||
fn stat(&self, _path: &str) -> Result<VfsEntry, VfsError> {
|
||||
Err(VfsError::NotFound("Not yet implemented".into()))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user