Add archive STDIO device driver (#443)
This commit is contained in:
parent
87734ae8d9
commit
175dd62a90
@ -86,7 +86,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <3ds/applets/miiselector.h>
|
#include <3ds/applets/miiselector.h>
|
||||||
|
|
||||||
#include <3ds/sdmc.h>
|
#include <3ds/archive.h>
|
||||||
#include <3ds/romfs.h>
|
#include <3ds/romfs.h>
|
||||||
#include <3ds/font.h>
|
#include <3ds/font.h>
|
||||||
#include <3ds/mii.h>
|
#include <3ds/mii.h>
|
||||||
@ -142,4 +142,3 @@ extern "C" {
|
|||||||
* @example threads/thread-basic/source/main.c
|
* @example threads/thread-basic/source/main.c
|
||||||
* @example time/rtc/source/main.c
|
* @example time/rtc/source/main.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
43
libctru/include/3ds/archive.h
Normal file
43
libctru/include/3ds/archive.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* @file archive.h
|
||||||
|
* @brief FS_Archive driver
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <3ds/types.h>
|
||||||
|
#include <3ds/services/fs.h>
|
||||||
|
|
||||||
|
#define ARCHIVE_DIRITER_MAGIC 0x68637261 /* "arch" */
|
||||||
|
|
||||||
|
/*! Open directory struct */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u32 magic; /*! "arch" */
|
||||||
|
Handle fd; /*! CTRU handle */
|
||||||
|
ssize_t index; /*! Current entry index */
|
||||||
|
size_t size; /*! Current batch size */
|
||||||
|
FS_DirectoryEntry entry_data[32]; /*! Temporary storage for reading entries */
|
||||||
|
} archive_dir_t;
|
||||||
|
|
||||||
|
/// Mounts the SD
|
||||||
|
Result archiveMountSdmc(void);
|
||||||
|
|
||||||
|
/// Mounts and opens an archive as deviceName
|
||||||
|
/// Returns either an archive open error code, or -1 for generic failure
|
||||||
|
Result archiveMount(FS_ArchiveID archiveID, FS_Path archivePath, const char *deviceName);
|
||||||
|
|
||||||
|
/// Uses FSUSER_ControlArchive with control action ARCHIVE_ACTION_COMMIT_SAVE_DATA on the opened archive. Not done automatically at unmount.
|
||||||
|
/// Returns -1 if the specified device is not found
|
||||||
|
Result archiveCommitSaveData(const char *deviceName);
|
||||||
|
|
||||||
|
/// Unmounts the specified device, closing its archive in the process
|
||||||
|
/// Returns -1 if the specified device was not found
|
||||||
|
Result archiveUnmount(const char *deviceName);
|
||||||
|
|
||||||
|
/// Unmounts all devices and cleans up any resources used by the driver
|
||||||
|
Result archiveUnmountAll(void);
|
||||||
|
|
||||||
|
/// Get a file's mtime
|
||||||
|
Result archive_getmtime(const char *name, u64 *mtime);
|
@ -1,34 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file sdmc.h
|
|
||||||
* @brief SDMC driver.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <3ds/types.h>
|
|
||||||
#include <3ds/services/fs.h>
|
|
||||||
|
|
||||||
#define SDMC_DIRITER_MAGIC 0x73646D63 /* "sdmc" */
|
|
||||||
|
|
||||||
/*! Open directory struct */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u32 magic; /*! "sdmc" */
|
|
||||||
Handle fd; /*! CTRU handle */
|
|
||||||
ssize_t index; /*! Current entry index */
|
|
||||||
size_t size; /*! Current batch size */
|
|
||||||
FS_DirectoryEntry entry_data[32]; /*! Temporary storage for reading entries */
|
|
||||||
} sdmc_dir_t;
|
|
||||||
|
|
||||||
/// Initializes the SDMC driver.
|
|
||||||
Result sdmcInit(void);
|
|
||||||
|
|
||||||
/// Enable/disable copy in sdmc_write
|
|
||||||
void sdmcWriteSafe(bool enable);
|
|
||||||
|
|
||||||
/// Exits the SDMC driver.
|
|
||||||
Result sdmcExit(void);
|
|
||||||
|
|
||||||
/// Get a file's mtime
|
|
||||||
Result sdmc_getmtime(const char *name, u64 *mtime);
|
|
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,14 @@
|
|||||||
#include <3ds/types.h>
|
#include <3ds/types.h>
|
||||||
#include <3ds/srv.h>
|
#include <3ds/srv.h>
|
||||||
#include <3ds/gfx.h>
|
#include <3ds/gfx.h>
|
||||||
#include <3ds/sdmc.h>
|
#include <3ds/archive.h>
|
||||||
#include <3ds/services/apt.h>
|
#include <3ds/services/apt.h>
|
||||||
#include <3ds/services/fs.h>
|
#include <3ds/services/fs.h>
|
||||||
#include <3ds/services/hid.h>
|
#include <3ds/services/hid.h>
|
||||||
|
|
||||||
void __attribute__((weak)) __appExit(void) {
|
void __attribute__((weak)) __appExit(void) {
|
||||||
// Exit services
|
// Exit services
|
||||||
sdmcExit();
|
archiveUnmountAll();
|
||||||
fsExit();
|
fsExit();
|
||||||
|
|
||||||
hidExit();
|
hidExit();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <3ds/types.h>
|
#include <3ds/types.h>
|
||||||
#include <3ds/srv.h>
|
#include <3ds/srv.h>
|
||||||
#include <3ds/gfx.h>
|
#include <3ds/gfx.h>
|
||||||
#include <3ds/sdmc.h>
|
#include <3ds/archive.h>
|
||||||
#include <3ds/services/apt.h>
|
#include <3ds/services/apt.h>
|
||||||
#include <3ds/services/fs.h>
|
#include <3ds/services/fs.h>
|
||||||
#include <3ds/services/hid.h>
|
#include <3ds/services/hid.h>
|
||||||
@ -13,5 +13,5 @@ void __attribute__((weak)) __appInit(void) {
|
|||||||
hidInit();
|
hidInit();
|
||||||
|
|
||||||
fsInit();
|
fsInit();
|
||||||
sdmcInit();
|
archiveMountSdmc();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user