Browse Source

Merge pull request #150 from rust3ds/remove/fs

Removal of all FS code and member renaming
pull/159/head
Meziu 12 months ago committed by GitHub
parent
commit
b1021c54ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      ctru-rs/Cargo.toml
  2. 10
      ctru-rs/examples/title-info.rs
  3. 18
      ctru-rs/src/services/am.rs
  4. 972
      ctru-rs/src/services/fs.rs

1
ctru-rs/Cargo.toml

@ -24,7 +24,6 @@ shim-3ds = { git = "https://github.com/rust3ds/shim-3ds.git" }
pthread-3ds = { git = "https://github.com/rust3ds/pthread-3ds.git" } pthread-3ds = { git = "https://github.com/rust3ds/pthread-3ds.git" }
libc = "0.2.121" libc = "0.2.121"
bitflags = "2.3.3" bitflags = "2.3.3"
widestring = "0.2.2"
[build-dependencies] [build-dependencies]
toml = "0.5" toml = "0.5"

10
ctru-rs/examples/title-info.rs

@ -5,7 +5,7 @@
use ctru::prelude::*; use ctru::prelude::*;
use ctru::services::am::Am; use ctru::services::am::Am;
use ctru::services::fs::FsMediaType; use ctru::services::fs::MediaType;
fn main() { fn main() {
let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); let gfx = Gfx::new().expect("Couldn't obtain GFX controller");
@ -20,20 +20,20 @@ fn main() {
// Amount of titles installed on the SD card. // Amount of titles installed on the SD card.
let sd_count = am let sd_count = am
.title_count(FsMediaType::Sd) .title_count(MediaType::Sd)
.expect("Failed to get sd title count"); .expect("Failed to get sd title count");
// List of titles installed on the SD card. // List of titles installed on the SD card.
let sd_list = am let sd_list = am
.title_list(FsMediaType::Sd) .title_list(MediaType::Sd)
.expect("Failed to get sd title list"); .expect("Failed to get sd title list");
// Amount of titles installed on the NAND storage. // Amount of titles installed on the NAND storage.
let nand_count = am let nand_count = am
.title_count(FsMediaType::Nand) .title_count(MediaType::Nand)
.expect("Failed to get nand title count"); .expect("Failed to get nand title count");
// List of titles installed on the NAND storage. // List of titles installed on the NAND storage.
let nand_list = am let nand_list = am
.title_list(FsMediaType::Nand) .title_list(MediaType::Nand)
.expect("Failed to get nand title list"); .expect("Failed to get nand title list");
let mut offset = 0; let mut offset = 0;

18
ctru-rs/src/services/am.rs

@ -9,14 +9,14 @@
#![doc(alias = "manager")] #![doc(alias = "manager")]
use crate::error::ResultCode; use crate::error::ResultCode;
use crate::services::fs::FsMediaType; use crate::services::fs::MediaType;
use std::marker::PhantomData; use std::marker::PhantomData;
/// General information about a specific title entry. /// General information about a specific title entry.
#[doc(alias = "AM_TitleEntry")] #[doc(alias = "AM_TitleEntry")]
pub struct Title<'a> { pub struct Title<'a> {
id: u64, id: u64,
mediatype: FsMediaType, mediatype: MediaType,
size: u64, size: u64,
version: u16, version: u16,
_am: PhantomData<&'a Am>, _am: PhantomData<&'a Am>,
@ -91,20 +91,20 @@ impl Am {
/// # fn main() -> Result<(), Box<dyn Error>> { /// # fn main() -> Result<(), Box<dyn Error>> {
/// # /// #
/// use ctru::services::am::Am; /// use ctru::services::am::Am;
/// use ctru::services::fs::FsMediaType; /// use ctru::services::fs::MediaType;
/// let app_manager = Am::new()?; /// let app_manager = Am::new()?;
/// ///
/// // Number of titles installed on the Nand storage. /// // Number of titles installed on the Nand storage.
/// let nand_count = app_manager.title_count(FsMediaType::Nand); /// let nand_count = app_manager.title_count(MediaType::Nand);
/// ///
/// // Number of apps installed on the SD card storage /// // Number of apps installed on the SD card storage
/// let sd_count = app_manager.title_count(FsMediaType::Sd); /// let sd_count = app_manager.title_count(MediaType::Sd);
/// # /// #
/// # Ok(()) /// # Ok(())
/// # } /// # }
/// ``` /// ```
#[doc(alias = "AM_GetTitleCount")] #[doc(alias = "AM_GetTitleCount")]
pub fn title_count(&self, mediatype: FsMediaType) -> crate::Result<u32> { pub fn title_count(&self, mediatype: MediaType) -> crate::Result<u32> {
unsafe { unsafe {
let mut count = 0; let mut count = 0;
ResultCode(ctru_sys::AM_GetTitleCount(mediatype.into(), &mut count))?; ResultCode(ctru_sys::AM_GetTitleCount(mediatype.into(), &mut count))?;
@ -122,11 +122,11 @@ impl Am {
/// # fn main() -> Result<(), Box<dyn Error>> { /// # fn main() -> Result<(), Box<dyn Error>> {
/// # /// #
/// use ctru::services::am::Am; /// use ctru::services::am::Am;
/// use ctru::services::fs::FsMediaType; /// use ctru::services::fs::MediaType;
/// let app_manager = Am::new()?; /// let app_manager = Am::new()?;
/// ///
/// // Number of apps installed on the SD card storage /// // Number of apps installed on the SD card storage
/// let sd_titles = app_manager.title_list(FsMediaType::Sd)?; /// let sd_titles = app_manager.title_list(MediaType::Sd)?;
/// ///
/// // Unique product code identifier of the 5th installed title. /// // Unique product code identifier of the 5th installed title.
/// let product_code = sd_titles[4].product_code(); /// let product_code = sd_titles[4].product_code();
@ -135,7 +135,7 @@ impl Am {
/// # } /// # }
/// ``` /// ```
#[doc(alias = "AM_GetTitleList")] #[doc(alias = "AM_GetTitleList")]
pub fn title_list(&self, mediatype: FsMediaType) -> crate::Result<Vec<Title>> { pub fn title_list(&self, mediatype: MediaType) -> crate::Result<Vec<Title>> {
let count = self.title_count(mediatype)?; let count = self.title_count(mediatype)?;
let mut buf = vec![0; count as usize]; let mut buf = vec![0; count as usize];
let mut read_amount = 0; let mut read_amount = 0;

972
ctru-rs/src/services/fs.rs

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save