Browse Source

Add basic RomFS support

Seems to crash the 3DS if there is no actual RomFS data in the 3dsx
file, so there's room for improvement.
pull/14/head
AzureMarker 3 years ago
parent
commit
07ed1dc196
No known key found for this signature in database
GPG Key ID: 47A133F3BF9D03D3
  1. 1
      ctru-rs/src/lib.rs
  2. 24
      ctru-rs/src/romfs.rs

1
ctru-rs/src/lib.rs

@ -34,6 +34,7 @@ pub mod console; @@ -34,6 +34,7 @@ pub mod console;
pub mod error;
pub mod gfx;
pub mod sdmc;
pub mod romfs;
pub mod services;
pub mod srv;
pub mod thread;

24
ctru-rs/src/romfs.rs

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
use std::ffi::CStr;
#[non_exhaustive]
pub struct RomFS;
impl RomFS {
pub fn new() -> crate::Result<Self> {
let mount_name = CStr::from_bytes_with_nul(b"romfs\0").unwrap();
let result = unsafe { ctru_sys::romfsMountSelf(mount_name.as_ptr()) };
if result < 0 {
Err(result.into())
} else {
Ok(Self)
}
}
}
impl Drop for RomFS {
fn drop(&mut self) {
let mount_name = CStr::from_bytes_with_nul(b"romfs\0").unwrap();
unsafe { ctru_sys::romfsUnmount(mount_name.as_ptr()) };
}
}
Loading…
Cancel
Save