nn::fs Namespace

Description

Namespace for the file system API.

You must first call the nn::fs::Initialize function to initialize the library before using any of the functions or classes in the nn::fs namespace.

The CTR file system is a collection of archives distinguished by their archive names. Each archive identifies files and directories and carries out the specified operation by receiving archive path name. Archive types differ in various ways such as their available operations, their restrictions on path names, and the number of files that can be opened, but all types can generally be accessed using the same interface.

Archives

The fs method of writing code for error handling is different than for other libraries.
In addition, the ways in which returned Result values are handled may differ depending on the type of archive being handled.

Error Handling

Namespaces

nn::fs::hio A namespace that includes functions used to directly access files on a PC (for debugging purposes).

Classes

File and Directory Operations
nn::fs::Directory A class used for directory operations.
nn::fs::FileInputStream Class for reading from files.
nn::fs::FileOutputStream Class for writing to files.
nn::fs::FileStream Class for reading from and writing to files.
Result
nn::fs::ResultNotFound File or archive not found.
nn::fs::ResultMediaNotFound Media not Found, Recognized. Errors Associated with ResultNotFound.
nn::fs::ResultAlreadyExists File or archive already exists.
nn::fs::ResultNotEnoughSpace Insufficient free space.
nn::fs::ResultArchiveInvalidated Invalid archive.
nn::fs::ResultOperationDenied Operation denied.
nn::fs::ResultWriteProtected Media is Write-protected. Errors Associated with ResultOperationDenied.
nn::fs::ResultMediaAccessError Errors Occurring during Media Access. Errors Associated with ResultOperationDenied.
nn::fs::ResultNotFormatted Not formatted.
nn::fs::ResultBadFormat Invalid format.
nn::fs::ResultVerificationFailed Verification failed.

Enumerated Types

OpenMode Enumerated type that indicates the file's open mode.
PositionBase Group of constants that indicate the position of file read/writes.

typedef Definitions

FileReader A typedef for FileInputStream.
FileWriter FileOutputStream type definition.

Functions

ROM Archives
GetRomRequiredMemorySize Gets the size of memory needed to mount a ROM archive.
MountRom Mounts a ROM archive.
Save Data Archives
FormatSaveData Formats a save data region.
MountSaveData Mounts a save data archive.
CommitSaveData Commits a change to the save data.
Expanded Save Data Archive
CreateExtSaveData Creates an expanded save data memory region.
MountExtSaveData Mounts expanded save data.
DeleteExtSaveData Deletes expanded save data.
For debugging purposes.
MountSdmc Mounts an archive that directly accesses the SD Memory Card (for debugging only).
ForceEnableLatencyEmulation Emulates the behavior of a non-volatile memory device that has become degraded. (for debugging purposes)
ForceDisableLatencyEmulation Turns off the function to emulate the behavior of a non-volatile memory device that has become degraded. (for debugging purposes)
Initialization
Initialize Initializes the FS library.
SD Card
RegisterSdmcInsertedEvent Registers the nn::os::LightEvent object that is signaled when an SD Memory Card is inserted.
UnregisterSdmcInsertedEvent Unregisters the nn::fs::RegisterSdmcInsertedEvent object.
RegisterSdmcEjectedEvent Registers the nn::os::LightEvent object that is signaled when an SD Memory Card is pulled out.
UnregisterSdmcEjectedEvent Unregisters the nn::fs::RegisterSdmcEjectedEvent object.
IsSdmcInserted Returns a value indicating whether an SD Card has been inserted.
IsSdmcWritable Returns a value indicating whether an SD Card is writable.
File and Directory Operations
DeleteFile Deletes a file.
TryDeleteFile Deletes a file.
RenameFile Renames a file.
TryRenameFile Renames a file.
DeleteDirectory Deletes a directory.
TryDeleteDirectory Deletes a directory.
TryDeleteDirectoryRecursively Deletes directories recursively.
CreateFile Creates a file.
TryCreateFile Creates a file.
CreateDirectory Creates a directory.
TryCreateDirectory Creates a directory.
RenameDirectory Renames a directory.
TryRenameDirectory Renames a directory.
Other
Unmount Unmounts an archive.
GetArchiveFreeBytes Gets the amount of free space in the archive.

Revision History

2010/11/13
Added the CommitSaveData and DeleteExtSaveData functions.
2010/11/09
Deleted the GetFileSystemSize and ReadExtSaveDataIcon functions.
2010/10/30
Added archive limitations, explanation about Result objects.
2010/09/22
Added a description of expanded save data.
2010/09/10
Added the MountSdmc function.
2010/09/09
Deleted the InitializeForFileSystemEvent, WaitForInsertSdmc, and WaitForEjectSdmc functions. Added the RegisterSdmcInsertedEvent, UnregisterSdmcInsertedEvent, RegisterSdmcEjectedEvent, and UnregisterSdmcEjectedEvent functions.
2010/01/07
Initial version.

CONFIDENTIAL