In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "NAND (SDK)"

From WiiBrew
Jump to navigation Jump to search
(←Created page with ''''NAND''' is an SDK library that provides filesystem functions. == Public functions == {| class="wikitable sortable" ! Signature ! Description |- | <code>int CreateFi...')
 
(Found official names for these functions in system menu 2.0)
Line 6: Line 6:
 
! Description
 
! Description
 
|-
 
|-
| <code>int CreateFile(char *path, int permissions, int attributes)</code>
+
| <code>int NANDCreate(char *path, int permissions, int attributes)</code>
 
| Creates a file. <code>path</code> can be a relative path, relative to the data directory of the active [[title]]. <code>permissions</code> is a single number that is put through a function to split it into permissions for owner/group/other. <code>attributes</code> is fed directly to [[:/dev/fs]].
 
| Creates a file. <code>path</code> can be a relative path, relative to the data directory of the active [[title]]. <code>permissions</code> is a single number that is put through a function to split it into permissions for owner/group/other. <code>attributes</code> is fed directly to [[:/dev/fs]].
 
|-
 
|-
| <code>int ReadFile(struct File *file, char *data, int len)</code>
+
| <code>int NANDRead(struct File *file, char *data, int len)</code>
 
| Equivalent to IOS_Read, but takes a <code>struct File</code> instead of an <code>fd</code>.
 
| Equivalent to IOS_Read, but takes a <code>struct File</code> instead of an <code>fd</code>.
 
|-
 
|-
| <code>int ReadFileAsync(struct File *file, char *data, int len, void (*callback)(int, void *), void *userData)</code>
+
| <code>int NANDReadAsync(struct File *file, char *data, int len, void (*callback)(int, void *), void *userData)</code>
| Asynchronous version of <code>ReadFile</code>
+
| Asynchronous version of <code>NANDRead</code>
 
|-
 
|-
| <code>int WriteFile(struct File *file, char *data, int len)</code>
+
| <code>int NANDWrite(struct File *file, char *data, int len)</code>
 
| Equivalent to IOS_Write, but takes a <code>struct File</code> instead of an <code>fd</code>.
 
| Equivalent to IOS_Write, but takes a <code>struct File</code> instead of an <code>fd</code>.
 
|-
 
|-
| <code>int OpenFile(char *path, struct File *file, int mode)</code>
+
| <code>int NANDOpen(char *path, struct File *file, int mode)</code>
 
| Opens the file with IOS_Open and initializes <code>file</code>. <code>path</code> can be a relative path, relative to the current title's data directory. Returns error -102 when trying to open any path starting with <code>[[:/shared2]]</code>.
 
| Opens the file with IOS_Open and initializes <code>file</code>. <code>path</code> can be a relative path, relative to the current title's data directory. Returns error -102 when trying to open any path starting with <code>[[:/shared2]]</code>.
 
|-
 
|-
| <code>int OpenFilePrivileged(char *path, struct File *file, int mode)</code>
+
| <code>int NANDPrivateOpen(char *path, struct File *file, int mode)</code>
| Same as <code>OpenFile</code>, except files in /shared2 are allowed.
+
| Same as <code>NANDOpen</code>, except files in /shared2 are allowed.
 
|-
 
|-
| <code>int OpenFileAsyncPrivileged(char *path, struct File *file, int mode, void (*callback)(int, void *), void *userData)</code>
+
| <code>int NANDPrivateOpenAsync(char *path, struct File *file, int mode, void (*callback)(int, void *), void *userData)</code>
| Same as <code>OpenFileAsync</code>, without the /shared2 check.
+
| Same as <code>NANDOpenAsync</code>, without the /shared2 check.
 
|-
 
|-
| <code>int CloseFile(struct File *file)</code>
+
| <code>int NANDClose(struct File *file)</code>
 
| Calls IOS_Close and marks <code>file</code> as closed.
 
| Calls IOS_Close and marks <code>file</code> as closed.
 
|-
 
|-
| <code>int CloseFileAsync(struct File *file, void (*callback)(int, void *), void *userData)</code>
+
| <code>int NANDCloseAsync(struct File *file, void (*callback)(int, void *), void *userData)</code>
 
| Calls IOS_CloseAsync and marks <code>file</code> as closed. Also sets <code>unknownAsync</code> to 7, although it is not known what this field actually does.
 
| Calls IOS_CloseAsync and marks <code>file</code> as closed. Also sets <code>unknownAsync</code> to 7, although it is not known what this field actually does.
 
|}
 
|}

Revision as of 23:07, 4 January 2022

NAND is an SDK library that provides filesystem functions.

Public functions

Signature Description
int NANDCreate(char *path, int permissions, int attributes) Creates a file. path can be a relative path, relative to the data directory of the active title. permissions is a single number that is put through a function to split it into permissions for owner/group/other. attributes is fed directly to /dev/fs.
int NANDRead(struct File *file, char *data, int len) Equivalent to IOS_Read, but takes a struct File instead of an fd.
int NANDReadAsync(struct File *file, char *data, int len, void (*callback)(int, void *), void *userData) Asynchronous version of NANDRead
int NANDWrite(struct File *file, char *data, int len) Equivalent to IOS_Write, but takes a struct File instead of an fd.
int NANDOpen(char *path, struct File *file, int mode) Opens the file with IOS_Open and initializes file. path can be a relative path, relative to the current title's data directory. Returns error -102 when trying to open any path starting with /shared2.
int NANDPrivateOpen(char *path, struct File *file, int mode) Same as NANDOpen, except files in /shared2 are allowed.
int NANDPrivateOpenAsync(char *path, struct File *file, int mode, void (*callback)(int, void *), void *userData) Same as NANDOpenAsync, without the /shared2 check.
int NANDClose(struct File *file) Calls IOS_Close and marks file as closed.
int NANDCloseAsync(struct File *file, void (*callback)(int, void *), void *userData) Calls IOS_CloseAsync and marks file as closed. Also sets unknownAsync to 7, although it is not known what this field actually does.

File struct

struct File {
	s32 fd;
	u8 unknown[0x85];
	u8 unknownAsync; // Set to 2 if the file is opened asynchronously, unset otherwise. Set to 7 if closed asynchronously.
	u8 status; // 1 = open, 2 = closed
}