|
|
@ -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; |
|
|
|