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.

The method of writing code for error handling is different for the FS library than for other libraries.
In addition, the handling method may differ depending on the returned Result value and the type of archive being manipulated.

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 A file, archive, or other filesystem entry could not be found.
nn::fs::ResultMediaNotFound Could not find or recognize media. This error is associated with ResultNotFound.
nn::fs::ResultAlreadyExists A file, archive, or other filesystem entry already exists.
nn::fs::ResultNotEnoughSpace There is no free space.
nn::fs::ResultArchiveInvalidated An archive has become invalid.
nn::fs::ResultOperationDenied An operation was denied.
nn::fs::ResultWriteProtected Write-protected. This error is associated with ResultOperationDenied.
nn::fs::ResultMediaAccessError An error occurred during media access. This error is associated with ResultOperationDenied.
nn::fs::ResultNotFormatted Data region not formatted.
nn::fs::ResultBadFormat Data region format invalid.
nn::fs::ResultVerificationFailed Either verification failed or some form of tampering was detected.
nn::fs::ResultOutOfResource Insufficient resources. You must not allow this error to occur in retail products.
nn::fs::ResultAccessDenied No access rights. You must not allow this error to occur in retail products.
nn::fs::ResultInvalidArgument The argument is invalid. You must not allow this error to occur in retail products.
nn::fs::ResultNotInitialized A process was called prior to the necessary initialization. You must not allow this error to occur in retail products.
nn::fs::ResultAlreadyInitialized Initialization was run twice. You must not allow this error to occur in retail products.
nn::fs::ResultUnsupportedOperation A feature that is not supported or an operation that is not allowed. You must not allow this error to occur in retail products.

Structures

nn::fs::Attributes Structure that gives attribute information for directory entries.
nn::fs::DirectoryEntry Structure representing a directory entry.

Enumerated Types

OpenMode Enumerated constant that specifies file open modes.
PositionBase Enumerated constant that indicates the position of file read/writes.

typedef Definitions

FileReader A typedef for FileInputStream.
FileWriter Typedef for FileOutputStream.

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 Archives
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.
GetSdmcSize Gets the total capacity and amount of free space on an SD Card.
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/12/09
Listed Result values that must be removed during development and added information on the nn::fs::Attributes and nn::fs::DirectoryEntry structures.
2010/11/25
Published the GetSdmcSize function
2010/11/13
Added the CommitSaveData and DeleteExtSaveData functions.
2010/11/09
Removed 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