diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index c2c8243..eef067d 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -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; diff --git a/ctru-rs/src/romfs.rs b/ctru-rs/src/romfs.rs new file mode 100644 index 0000000..09cfaa1 --- /dev/null +++ b/ctru-rs/src/romfs.rs @@ -0,0 +1,24 @@ +use std::ffi::CStr; + +#[non_exhaustive] +pub struct RomFS; + +impl RomFS { + pub fn new() -> crate::Result { + 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()) }; + } +} \ No newline at end of file