Skip to content

Commit 175dd62

Browse files
authored
Add archive STDIO device driver (#443)
1 parent 87734ae commit 175dd62

6 files changed

Lines changed: 561 additions & 359 deletions

File tree

libctru/include/3ds.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extern "C" {
8686

8787
#include <3ds/applets/miiselector.h>
8888

89-
#include <3ds/sdmc.h>
89+
#include <3ds/archive.h>
9090
#include <3ds/romfs.h>
9191
#include <3ds/font.h>
9292
#include <3ds/mii.h>
@@ -142,4 +142,3 @@ extern "C" {
142142
* @example threads/thread-basic/source/main.c
143143
* @example time/rtc/source/main.c
144144
*/
145-

libctru/include/3ds/archive.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @file archive.h
3+
* @brief FS_Archive driver
4+
*/
5+
#pragma once
6+
7+
#include <sys/types.h>
8+
9+
#include <3ds/types.h>
10+
#include <3ds/services/fs.h>
11+
12+
#define ARCHIVE_DIRITER_MAGIC 0x68637261 /* "arch" */
13+
14+
/*! Open directory struct */
15+
typedef struct
16+
{
17+
u32 magic; /*! "arch" */
18+
Handle fd; /*! CTRU handle */
19+
ssize_t index; /*! Current entry index */
20+
size_t size; /*! Current batch size */
21+
FS_DirectoryEntry entry_data[32]; /*! Temporary storage for reading entries */
22+
} archive_dir_t;
23+
24+
/// Mounts the SD
25+
Result archiveMountSdmc(void);
26+
27+
/// Mounts and opens an archive as deviceName
28+
/// Returns either an archive open error code, or -1 for generic failure
29+
Result archiveMount(FS_ArchiveID archiveID, FS_Path archivePath, const char *deviceName);
30+
31+
/// Uses FSUSER_ControlArchive with control action ARCHIVE_ACTION_COMMIT_SAVE_DATA on the opened archive. Not done automatically at unmount.
32+
/// Returns -1 if the specified device is not found
33+
Result archiveCommitSaveData(const char *deviceName);
34+
35+
/// Unmounts the specified device, closing its archive in the process
36+
/// Returns -1 if the specified device was not found
37+
Result archiveUnmount(const char *deviceName);
38+
39+
/// Unmounts all devices and cleans up any resources used by the driver
40+
Result archiveUnmountAll(void);
41+
42+
/// Get a file's mtime
43+
Result archive_getmtime(const char *name, u64 *mtime);

libctru/include/3ds/sdmc.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)