My Project
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
fs.h File Reference
#include <string.h>
#include <3ds/types.h>

Go to the source code of this file.

Data Structures

struct  FS_path
 
struct  FS_archive
 
struct  FS_dirent
 

Macros

#define FS_OPEN_READ   (1<<0)
 
#define FS_OPEN_WRITE   (1<<1)
 
#define FS_OPEN_CREATE   (1<<2)
 
#define FS_ATTRIBUTE_NONE   (0x00000000)
 
#define FS_ATTRIBUTE_READONLY   (0x00000001)
 
#define FS_ATTRIBUTE_ARCHIVE   (0x00000100)
 
#define FS_ATTRIBUTE_HIDDEN   (0x00010000)
 
#define FS_ATTRIBUTE_DIRECTORY   (0x01000000)
 
#define FS_WRITE_NOFLUSH   (0x00000000)
 
#define FS_WRITE_FLUSH   (0x00010001)
 

Enumerations

enum  FS_pathType {
  PATH_INVALID = 0, PATH_EMPTY = 1, PATH_BINARY = 2, PATH_CHAR = 3,
  PATH_WCHAR = 4
}
 
enum  FS_archiveIds {
  ARCH_ROMFS = 0x3, ARCH_SAVEDATA = 0x4, ARCH_EXTDATA = 0x6, ARCH_SHARED_EXTDATA = 0x7,
  ARCH_SYSTEM_SAVEDATA = 0x8, ARCH_SDMC = 0x9, ARCH_SDMC_WRITE_ONLY = 0xA, ARCH_BOSS_EXTDATA = 0x12345678,
  ARCH_CARD_SPIFS = 0x12345679, ARCH_NAND_RW = 0x1234567D, ARCH_NAND_RO = 0x1234567E, ARCH_NAND_RO_WRITE_ACCESS = 0x1234567F
}
 

Functions

Result fsInit (void)
 
Result fsExit (void)
 
Result FSUSER_Initialize (Handle *handle)
 
Result FSUSER_OpenArchive (Handle *handle, FS_archive *archive)
 
Result FSUSER_OpenDirectory (Handle *handle, Handle *out, FS_archive archive, FS_path dirLowPath)
 
Result FSUSER_OpenFile (Handle *handle, Handle *out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes)
 
Result FSUSER_OpenFileDirectly (Handle *handle, Handle *out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes)
 
Result FSUSER_CloseArchive (Handle *handle, FS_archive *archive)
 
Result FSUSER_CreateDirectory (Handle *handle, FS_archive archive, FS_path dirLowPath)
 
Result FSUSER_DeleteFile (Handle *handle, FS_archive archive, FS_path fileLowPath)
 
Result FSUSER_DeleteDirectory (Handle *handle, FS_archive archive, FS_path dirLowPath)
 
Result FSUSER_RenameFile (Handle *handle, FS_archive srcArchive, FS_path srcFileLowPath, FS_archive destArchive, FS_path destFileLowPath)
 
Result FSUSER_RenameDirectory (Handle *handle, FS_archive srcArchive, FS_path srcDirLowPath, FS_archive destArchive, FS_path destDirLowPath)
 
Result FSUSER_GetSdmcArchiveResource (Handle *handle, u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters)
 
Result FSUSER_IsSdmcDetected (Handle *handle, u32 *detected)
 
Result FSUSER_IsSdmcWritable (Handle *handle, u32 *writable)
 
Result FSFILE_Close (Handle handle)
 
Result FSFILE_Read (Handle handle, u32 *bytesRead, u64 offset, void *buffer, u32 size)
 
Result FSFILE_Write (Handle handle, u32 *bytesWritten, u64 offset, const void *buffer, u32 size, u32 flushFlags)
 
Result FSFILE_GetSize (Handle handle, u64 *size)
 
Result FSFILE_SetSize (Handle handle, u64 size)
 
Result FSFILE_GetAttributes (Handle handle, u32 *attributes)
 
Result FSFILE_SetAttributes (Handle handle, u32 attributes)
 
Result FSFILE_Flush (Handle handle)
 
Result FSDIR_Read (Handle handle, u32 *entriesRead, u32 entrycount, FS_dirent *buffer)
 
Result FSDIR_Close (Handle handle)
 

Detailed Description

Filesystem Services

Definition in file fs.h.

Enumeration Type Documentation

FS archive ids

Enumerator
ARCH_ROMFS 
ARCH_SAVEDATA 
ARCH_EXTDATA 
ARCH_SHARED_EXTDATA 
ARCH_SYSTEM_SAVEDATA 
ARCH_SDMC 
ARCH_SDMC_WRITE_ONLY 
ARCH_BOSS_EXTDATA 
ARCH_CARD_SPIFS 
ARCH_NAND_RW 
ARCH_NAND_RO 
ARCH_NAND_RO_WRITE_ACCESS 

Definition at line 71 of file fs.h.

FS path type

Enumerator
PATH_INVALID 

Specifies an invalid path.

PATH_EMPTY 

Specifies an empty path.

PATH_BINARY 

Specifies a binary path, which is non-text based.

PATH_CHAR 

Specifies a text based path with a 8-bit byte per character.

PATH_WCHAR 

Specifies a text based path with a 16-bit short per character.

Definition at line 61 of file fs.h.

Function Documentation

Result FSDIR_Close ( Handle  handle)

Close an open directory

Parameters
[in]handleOpen directory handle
Returns
error

Definition at line 1325 of file fs.c.

Result FSDIR_Read ( Handle  handle,
u32 entriesRead,
u32  entryCount,
FS_dirent buffer 
)

Read a directory entry from an open directory

Parameters
[in]handleOpen directory handle
[out]entriesReadOutput number of entries read
[in]entryCountNumber of entries to read
[out]bufferOutput buffer
Returns
error

Definition at line 1281 of file fs.c.

Result fsExit ( void  )

Deinitialize FS service

Returns
error

Definition at line 35 of file fs.c.

Result FSFILE_Close ( Handle  handle)

Close an open file

Parameters
[in]handleOpen file handle
Returns
error

Definition at line 911 of file fs.c.

Result FSFILE_Flush ( Handle  handle)

Flush an open file

Parameters
[in]handleOpen file handle
Returns
error

Definition at line 1239 of file fs.c.

Result FSFILE_GetAttributes ( Handle  handle,
u32 attributes 
)

Get attributes for an open file

Parameters
[in]handleOpen file handle
[out]attributesOutput attributes
Returns
error

Definition at line 1161 of file fs.c.

Result FSFILE_GetSize ( Handle  handle,
u64 size 
)

Get the size of an open file

Parameters
[in]handleOpen file handle
[out]sizeOutput size
Returns
error

Definition at line 1078 of file fs.c.

Result FSFILE_Read ( Handle  handle,
u32 bytesRead,
u64  offset,
void *  buffer,
u32  size 
)

Read data from an open file

Parameters
[in]handleOpen file handle
[out]bytesReadNumber of bytes read
[in]offsetFile offset to read from
[out]bufferBuffer to read into
[in]sizeNumber of bytes to read
Returns
error

Definition at line 959 of file fs.c.

Result FSFILE_SetAttributes ( Handle  handle,
u32  attributes 
)

Set attributes for an open file

Parameters
[in]handleOpen file handle
[in]attributesAttributes to set
Returns
error

Definition at line 1202 of file fs.c.

Result FSFILE_SetSize ( Handle  handle,
u64  size 
)

Set the size of an open file

Parameters
[in]handleOpen file handle
[in]sizeSize to set
Returns
error

Definition at line 1120 of file fs.c.

Result FSFILE_Write ( Handle  handle,
u32 bytesWritten,
u64  offset,
const void *  buffer,
u32  size,
u32  flushFlags 
)

Write data to an open file

Parameters
[in]handleOpen file handle
[out]bytesWrittenNumber of bytes read
[in]offsetFile offset to write to
[in]bufferBuffer to write from
[in]sizeNumber of bytes to write
[in]flushFlagsFlush flags
Returns
error
See also
FS Flush Flags
Warning
Using invalid flushFlags can corrupt the archive you're writing to.
Data should not be in read-only memory.

Definition at line 1026 of file fs.c.

Result fsInit ( void  )

Initialize FS service

Returns
error

Definition at line 22 of file fs.c.

Result FSUSER_CloseArchive ( Handle handle,
FS_archive archive 
)

Close an open archive

Parameters
[in]handlefs:USER handle
[in,out]archiveArchive to close
Returns
error

Definition at line 717 of file fs.c.

Result FSUSER_CreateDirectory ( Handle handle,
FS_archive  archive,
FS_path  dirLowPath 
)

Create a directory

Parameters
[in]handlefs:USER handle
[in]archiveOpen archive
[in]dirLowPathDirectory path to create
Returns
error

Definition at line 475 of file fs.c.

Result FSUSER_DeleteDirectory ( Handle handle,
FS_archive  archive,
FS_path  dirLowPath 
)

Delete a directory

Parameters
[in]handlefs:USER handle
[in]archiveOpen archive
[in]dirLowPathDirectory path
Returns
error

Definition at line 404 of file fs.c.

Result FSUSER_DeleteFile ( Handle handle,
FS_archive  archive,
FS_path  fileLowPath 
)

Delete a file

Parameters
[in]handlefs:USER handle
[in]archiveOpen archive
[in]fileLowPathFile path
Returns
error

Definition at line 276 of file fs.c.

Result FSUSER_GetSdmcArchiveResource ( Handle handle,
u32 sectorSize,
u32 clusterSize,
u32 numClusters,
u32 freeClusters 
)

Get SD FAT information

Parameters
[in]handlefs:USER handle
[out]sectorSizeSector size (bytes)
[out]clusterSizeCluster size (bytes)
[out]numClustersTotal number of clusters
[out]freeClustersNumber of free clusters
Returns
error

Definition at line 769 of file fs.c.

Result FSUSER_Initialize ( Handle handle)

Initialize FS service handle

If handle is NULL, this initializes fsuHandle.

Parameters
[in]handlefs:USER service handle
Returns
error

Definition at line 65 of file fs.c.

Result FSUSER_IsSdmcDetected ( Handle handle,
u32 detected 
)

Check if SD card is detected

Parameters
[in]handlefs:USER handle
[out]detectedOutput detected state
Returns
error

Definition at line 825 of file fs.c.

Result FSUSER_IsSdmcWritable ( Handle handle,
u32 writable 
)

Check if SD card is writable

Parameters
[in]handlefs:USER handle
[out]writableOutput writable state
Returns
error

Definition at line 869 of file fs.c.

Result FSUSER_OpenArchive ( Handle handle,
FS_archive archive 
)

Open an archive

Parameters
[in]handlefs:USER handle
[in,out]archiveArchive to open
Returns
error

Definition at line 663 of file fs.c.

Result FSUSER_OpenDirectory ( Handle handle,
Handle out,
FS_archive  archive,
FS_path  dirLowPath 
)

Open a directory

Parameters
[in]handlefs:USER handle
[out]outOutput handle
[in]archiveOpen archive
[in]dirLowPathDirectory path
Returns
error

Definition at line 605 of file fs.c.

Result FSUSER_OpenFile ( Handle handle,
Handle out,
FS_archive  archive,
FS_path  fileLowPath,
u32  openFlags,
u32  attributes 
)

Open a file

Parameters
[in]handlefs:USER handle
[out]outOutput handle
[in]archiveOpen archive
[in]fileLowPathFile path
[in]openFlagsOpen flags
[in]attributesCreate attributes
Note
This requires archive to have been opened
Returns
error
See also
FS Open Flags
FS Create Attributes

Definition at line 130 of file fs.c.

Result FSUSER_OpenFileDirectly ( Handle handle,
Handle out,
FS_archive  archive,
FS_path  fileLowPath,
u32  openFlags,
u32  attributes 
)

Open a file

Parameters
[in]handlefs:USER handle
[out]outOutput handle
[in]archiveOpen archive
[in]fileLowPathFile path
[in]openFlagsOpen flags
[in]attributesCreate attributes
Note
This does not require archive to have been opened
Returns
error
See also
FS Open Flags
FS Create Attributes

Definition at line 209 of file fs.c.

Result FSUSER_RenameDirectory ( Handle handle,
FS_archive  srcArchive,
FS_path  srcDirLowPath,
FS_archive  destArchive,
FS_path  destDirLowPath 
)

Renames or moves a directory.

Parameters
[in]handlefs:USER handle
[in]srcArchiveOpen archive of source
[in]srcDirLowPathDir path to source
[in]destArchiveOpen archive of destination
[in]destDirLowPathDir path to destination
Returns
error

Definition at line 540 of file fs.c.

Result FSUSER_RenameFile ( Handle handle,
FS_archive  srcArchive,
FS_path  srcFileLowPath,
FS_archive  destArchive,
FS_path  destFileLowPath 
)

Renames or moves a file.

Parameters
[in]handlefs:USER handle
[in]srcArchiveOpen archive of source
[in]srcFileLowPathFile path to source
[in]destArchiveOpen archive of destination
[in]destFileLowPathFile path to destination
Returns
error

Definition at line 340 of file fs.c.