Skip to content

Commit

Permalink
Add archive STDIO device driver (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
piepie62 committed Apr 15, 2020
1 parent 87734ae commit 175dd62
Show file tree
Hide file tree
Showing 6 changed files with 561 additions and 359 deletions.
3 changes: 1 addition & 2 deletions libctru/include/3ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extern "C" {

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

#include <3ds/sdmc.h>
#include <3ds/archive.h>
#include <3ds/romfs.h>
#include <3ds/font.h>
#include <3ds/mii.h>
Expand Down Expand Up @@ -142,4 +142,3 @@ extern "C" {
* @example threads/thread-basic/source/main.c
* @example time/rtc/source/main.c
*/

43 changes: 43 additions & 0 deletions libctru/include/3ds/archive.h
Original file line number Diff line number Diff line change
@@ -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);
34 changes: 0 additions & 34 deletions libctru/include/3ds/sdmc.h

This file was deleted.

0 comments on commit 175dd62

Please sign in to comment.