romfs.h
Go to the documentation of this file.
/**
* @file romfs.h
* @brief RomFS driver.
*/
#pragma once
#include <3ds/types.h>
#include <3ds/services/fs.h>
/// RomFS header.
typedef struct
{
u32 headerSize; ///< Size of the header.
u32 dirHashTableOff; ///< Offset of the directory hash table.
u32 dirHashTableSize; ///< Size of the directory hash table.
u32 dirTableOff; ///< Offset of the directory table.
u32 dirTableSize; ///< Size of the directory table.
u32 fileHashTableOff; ///< Offset of the file hash table.
u32 fileHashTableSize; ///< Size of the file hash table.
u32 fileTableOff; ///< Offset of the file table.
u32 fileTableSize; ///< Size of the file table.
u32 fileDataOff; ///< Offset of the file data.
} romfs_header;
/// RomFS directory.
typedef struct
{
u32 parent; ///< Offset of the parent directory.
u32 sibling; ///< Offset of the next sibling directory.
u32 childDir; ///< Offset of the first child directory.
u32 childFile; ///< Offset of the first file.
u32 nextHash; ///< Directory hash table pointer.
u32 nameLen; ///< Name length.
u16 name[]; ///< Name. (UTF-16)
} romfs_dir;
/// RomFS file.
typedef struct
{
u32 parent; ///< Offset of the parent directory.
u32 sibling; ///< Offset of the next sibling file.
u64 dataOff; ///< Offset of the file's data.
u64 dataSize; ///< Length of the file's data.
u32 nextHash; ///< File hash table pointer.
u32 nameLen; ///< Name length.
u16 name[]; ///< Name. (UTF-16)
} romfs_file;
/**
* @brief Mounts the Application's RomFS.
* @param name Device mount name.
* @remark This function is intended to be used to access one's own RomFS.
* If the application is running as 3DSX, it mounts the embedded RomFS section inside the 3DSX.
* If on the other hand it's an NCCH, it behaves identically to \ref romfsMountFromCurrentProcess.
*/
Result romfsMountSelf(const char *name);
/**
* @brief Mounts RomFS from an open file.
* @param fd FSFILE handle of the RomFS image.
* @param offset Offset of the RomFS within the file.
* @param name Device mount name.
*/
Result romfsMountFromFile(Handle fd, u32 offset, const char *name);
/**
* @brief Mounts RomFS using the current process host program RomFS.
* @param name Device mount name.
*/
Result romfsMountFromCurrentProcess(const char *name);
/**
* @brief Mounts RomFS from the specified title.
* @param tid Title ID
* @param mediatype Mediatype
* @param name Device mount name.
*/
Result romfsMountFromTitle(u64 tid, FS_MediaType mediatype, const char* name);
/// Unmounts the RomFS device.
Result romfsUnmount(const char *name);
/// Wrapper for \ref romfsMountSelf with the default "romfs" device name.
static inline Result romfsInit(void)
{
return romfsMountSelf("romfs");
}
/// Wrapper for \ref romfsUnmount with the default "romfs" device name.
static inline Result romfsExit(void)
{
return romfsUnmount("romfs");
}
fs.h
Filesystem Services.
FS_MediaType
FS_MediaType
Media types.
Definition: fs.h:35
romfsInit
static Result romfsInit(void)
Wrapper for romfsMountSelf with the default "romfs" device name.
Definition: romfs.h:84
romfsMountFromTitle
Result romfsMountFromTitle(u64 tid, FS_MediaType mediatype, const char *name)
Mounts RomFS from the specified title.
romfsMountFromCurrentProcess
Result romfsMountFromCurrentProcess(const char *name)
Mounts RomFS using the current process host program RomFS.
romfsMountFromFile
Result romfsMountFromFile(Handle fd, u32 offset, const char *name)
Mounts RomFS from an open file.
romfsMountSelf
Result romfsMountSelf(const char *name)
Mounts the Application's RomFS.
romfsExit
static Result romfsExit(void)
Wrapper for romfsUnmount with the default "romfs" device name.
Definition: romfs.h:90
romfsUnmount
Result romfsUnmount(const char *name)
Unmounts the RomFS device.
romfs_dir
RomFS directory.
Definition: romfs.h:27
romfs_dir::nameLen
u32 nameLen
Name length.
Definition: romfs.h:33
romfs_dir::childDir
u32 childDir
Offset of the first child directory.
Definition: romfs.h:30
romfs_dir::parent
u32 parent
Offset of the parent directory.
Definition: romfs.h:28
romfs_dir::sibling
u32 sibling
Offset of the next sibling directory.
Definition: romfs.h:29
romfs_dir::childFile
u32 childFile
Offset of the first file.
Definition: romfs.h:31
romfs_dir::nextHash
u32 nextHash
Directory hash table pointer.
Definition: romfs.h:32
romfs_file
RomFS file.
Definition: romfs.h:39
romfs_file::sibling
u32 sibling
Offset of the next sibling file.
Definition: romfs.h:41
romfs_file::dataSize
u64 dataSize
Length of the file's data.
Definition: romfs.h:43
romfs_file::nameLen
u32 nameLen
Name length.
Definition: romfs.h:45
romfs_file::nextHash
u32 nextHash
File hash table pointer.
Definition: romfs.h:44
romfs_file::dataOff
u64 dataOff
Offset of the file's data.
Definition: romfs.h:42
romfs_file::parent
u32 parent
Offset of the parent directory.
Definition: romfs.h:40
romfs_header
RomFS header.
Definition: romfs.h:12
romfs_header::headerSize
u32 headerSize
Size of the header.
Definition: romfs.h:13
romfs_header::fileTableOff
u32 fileTableOff
Offset of the file table.
Definition: romfs.h:20
romfs_header::fileHashTableOff
u32 fileHashTableOff
Offset of the file hash table.
Definition: romfs.h:18
romfs_header::dirTableSize
u32 dirTableSize
Size of the directory table.
Definition: romfs.h:17
romfs_header::fileDataOff
u32 fileDataOff
Offset of the file data.
Definition: romfs.h:22
romfs_header::dirHashTableSize
u32 dirHashTableSize
Size of the directory hash table.
Definition: romfs.h:15
romfs_header::fileTableSize
u32 fileTableSize
Size of the file table.
Definition: romfs.h:21
romfs_header::fileHashTableSize
u32 fileHashTableSize
Size of the file hash table.
Definition: romfs.h:19
romfs_header::dirTableOff
u32 dirTableOff
Offset of the directory table.
Definition: romfs.h:16
romfs_header::dirHashTableOff
u32 dirHashTableOff
Offset of the directory hash table.
Definition: romfs.h:14
types.h
Various system types.
u64
uint64_t u64
64-bit unsigned integer
Definition: types.h:24
Handle
u32 Handle
Resource handle.
Definition: types.h:41
Result
s32 Result
Function result.
Definition: types.h:42
u16
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
u32
uint32_t u32
32-bit unsigned integer
Definition: types.h:23