WUT  0.1
Wii U Toolchain
filesystem.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 typedef uint32_t FSDirectoryHandle;
22 typedef uint32_t FSFileHandle;
23 typedef uint32_t FSPriority;
24 
25 typedef struct FSAsyncData FSAsyncData;
26 typedef struct FSCmdBlock FSCmdBlock;
27 typedef struct FSClient FSClient;
29 typedef struct FSStat FSStat;
31 
32 typedef enum FSStatus
33 {
53 } FSStatus;
54 
55 typedef enum FSError
56 {
57  FS_ERROR_NOT_INIT = -0x30001,
58  FS_ERROR_BUSY = -0x30002,
59  FS_ERROR_CANCELLED = -0x30003,
60  FS_ERROR_END_OF_DIR = -0x30004,
65  FS_ERROR_MAX_FILES = -0x30013,
66  FS_ERROR_MAX_DIRS = -0x30014,
69  FS_ERROR_NOT_FOUND = -0x30017,
70  FS_ERROR_NOT_EMPTY = -0x30018,
85  FS_ERROR_NOT_FILE = -0x30028,
86  FS_ERROR_NOT_DIR = -0x30029,
94 } FSError;
95 
96 typedef enum FSStatFlags
97 {
98  FS_STAT_DIRECTORY = 0x80000000,
99 } FSStatFlags;
100 
101 typedef enum FSVolumeState
102 {
115 } FSVolumeState;
116 
117 typedef void(*FSAsyncCallback)(FSClient *, FSCmdBlock *, FSStatus, uint32_t);
118 
119 struct FSClient
120 {
121  UNKNOWN(0x1700);
122 };
123 CHECK_SIZE(FSClient, 0x1700);
124 
125 struct FSCmdBlock
126 {
127  UNKNOWN(0xA80);
128 };
129 CHECK_SIZE(FSCmdBlock, 0xA80);
130 
131 struct FSStat
132 {
134  UNKNOWN(0xC);
135  uint32_t size;
136  UNKNOWN(0x50);
137 };
138 CHECK_OFFSET(FSStat, 0x00, flags);
139 CHECK_OFFSET(FSStat, 0x10, size);
140 CHECK_SIZE(FSStat, 0x64);
141 
143 {
144  UNKNOWN(0xC);
145 };
146 CHECK_SIZE(FSStateChangeInfo, 0xC);
147 
149 {
150  uint32_t callback;
151  uint32_t param;
152  UNKNOWN(4);
153 };
154 CHECK_OFFSET(FSAsyncData, 0x0, callback);
155 CHECK_OFFSET(FSAsyncData, 0x4, param);
156 CHECK_SIZE(FSAsyncData, 0xC);
157 
159 {
161  char name[256];
162 };
163 CHECK_OFFSET(FSDirectoryEntry, 0x64, name);
164 CHECK_SIZE(FSDirectoryEntry, 0x164);
165 
166 void
167 FSInit();
168 
169 void
170 FSShutdown();
171 
172 FSStatus
173 FSAddClient(FSClient *client,
174  uint32_t flags);
175 
176 FSStatus
177 FSDelClient(FSClient *client,
178  uint32_t flags);
179 
180 uint32_t
182 
183 void
184 FSInitCmdBlock(FSCmdBlock *block);
185 
186 FSStatus
187 FSSetCmdPriority(FSCmdBlock *block,
188  FSPriority priority);
189 
190 void
191 FSSetStateChangeNotification(FSClient *client,
192  FSStateChangeInfo *info);
193 
194 FSStatus
195 FSGetCwd(FSClient *client,
196  FSCmdBlock *block,
197  char *buffer,
198  uint32_t bufferSize,
199  uint32_t flags);
200 
201 FSStatus
202 FSChangeDir(FSClient *client,
203  FSCmdBlock *block,
204  const char *path,
205  uint32_t flags);
206 
207 FSStatus
208 FSChangeDirAsync(FSClient *client,
209  FSCmdBlock *block,
210  const char *path,
211  uint32_t flags,
212  FSAsyncData *asyncData);
213 
214 FSStatus
215 FSGetStat(FSClient *client,
216  FSCmdBlock *block,
217  const char *path,
218  FSStat *stat,
219  uint32_t flags);
220 
221 FSStatus
222 FSGetStatAsync(FSClient *client,
223  FSCmdBlock *block,
224  const char *path,
225  FSStat *stat,
226  uint32_t flags,
227  FSAsyncData *asyncData);
228 
229 FSStatus
230 FSOpenFile(FSClient *client,
231  FSCmdBlock *block,
232  const char *path,
233  const char *mode,
234  FSFileHandle *handle,
235  uint32_t flags);
236 
237 FSStatus
238 FSOpenFileAsync(FSClient *client,
239  FSCmdBlock *block,
240  const char *path,
241  const char *mode,
242  FSFileHandle *outHandle,
243  uint32_t flags,
244  FSAsyncData *asyncData);
245 
246 FSStatus
247 FSCloseFile(FSClient *client,
248  FSCmdBlock *block,
249  FSFileHandle handle,
250  uint32_t flags);
251 
252 FSStatus
253 FSCloseFileAsync(FSClient *client,
254  FSCmdBlock *block,
255  FSFileHandle handle,
256  uint32_t flags,
257  FSAsyncData *asyncData);
258 
259 FSStatus
260 FSOpenDir(FSClient *client,
261  FSCmdBlock *block,
262  const char *path,
263  FSDirectoryHandle *handle,
264  uint32_t flags);
265 
266 FSStatus
267 FSOpenDirAsync(FSClient *client,
268  FSCmdBlock *block,
269  const char *path,
270  FSDirectoryHandle *handle,
271  uint32_t flags,
272  FSAsyncData *asyncData);
273 
274 FSStatus
275 FSReadDir(FSClient *client,
276  FSCmdBlock *block,
277  FSDirectoryHandle handle,
278  FSDirectoryEntry *entry,
279  uint32_t flags);
280 
281 FSStatus
282 FSReadDirAsync(FSClient *client,
283  FSCmdBlock *block,
284  FSDirectoryHandle handle,
285  FSDirectoryEntry *entry,
286  uint32_t flags,
287  FSAsyncData *asyncData);
288 
289 FSStatus
290 FSCloseDir(FSClient *client,
291  FSCmdBlock *block,
292  FSDirectoryHandle handle,
293  uint32_t flags);
294 
295 FSStatus
296 FSCloseDirAsync(FSClient *client,
297  FSCmdBlock *block,
298  FSDirectoryHandle handle,
299  uint32_t flags,
300  FSAsyncData *asyncData);
301 
302 FSStatus
303 FSGetStatFile(FSClient *client,
304  FSCmdBlock *block,
305  FSFileHandle handle,
306  FSStat *stat,
307  uint32_t flags);
308 
309 FSStatus
310 FSGetStatFileAsync(FSClient *client,
311  FSCmdBlock *block,
312  FSFileHandle handle,
313  FSStat *stat,
314  uint32_t flags,
315  FSAsyncData *asyncData);
316 
317 FSStatus
318 FSReadFile(FSClient *client,
319  FSCmdBlock *block,
320  uint8_t *buffer,
321  uint32_t size,
322  uint32_t count,
323  FSFileHandle handle,
324  uint32_t unk1,
325  uint32_t flags);
326 
327 FSStatus
328 FSReadFileAsync(FSClient *client,
329  FSCmdBlock *block,
330  uint8_t *buffer,
331  uint32_t size,
332  uint32_t count,
333  FSFileHandle handle,
334  uint32_t unk1,
335  uint32_t flags,
336  FSAsyncData *asyncData);
337 
338 FSStatus
339 FSReadFileWithPos(FSClient *client,
340  FSCmdBlock *block,
341  uint8_t *buffer,
342  uint32_t size,
343  uint32_t count,
344  uint32_t pos,
345  FSFileHandle handle,
346  uint32_t unk1,
347  uint32_t flags);
348 
349 FSStatus
350 FSReadFileWithPosAsync(FSClient *client,
351  FSCmdBlock *block,
352  uint8_t *buffer,
353  uint32_t size,
354  uint32_t count,
355  uint32_t pos,
356  FSFileHandle handle,
357  uint32_t unk1,
358  uint32_t flags,
359  FSAsyncData *asyncData);
360 
361 FSStatus
362 FSGetPosFile(FSClient *client,
363  FSCmdBlock *block,
364  FSFileHandle fileHandle,
365  uint32_t *pos,
366  uint32_t flags);
367 
368 FSStatus
369 FSGetPosFileAsync(FSClient *client,
370  FSCmdBlock *block,
371  FSFileHandle fileHandle,
372  uint32_t *pos,
373  uint32_t flags,
374  FSAsyncData *asyncData);
375 
376 FSStatus
377 FSSetPosFile(FSClient *client,
378  FSCmdBlock *block,
379  FSFileHandle handle,
380  uint32_t pos,
381  uint32_t flags);
382 
383 FSStatus
384 FSSetPosFileAsync(FSClient *client,
385  FSCmdBlock *block,
386  FSFileHandle handle,
387  uint32_t pos,
388  uint32_t flags,
389  FSAsyncData *asyncData);
390 
392 FSGetVolumeState(FSClient *client);
393 
394 FSError
395 FSGetLastErrorCodeForViewer(FSClient *client);
396 
397 #ifdef __cplusplus
398 }
399 #endif
400 
FSStatus FSCloseDir(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, uint32_t flags)
FSStatus FSGetPosFileAsync(FSClient *client, FSCmdBlock *block, FSFileHandle fileHandle, uint32_t *pos, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSSetCmdPriority(FSCmdBlock *block, FSPriority priority)
uint32_t param
Definition: filesystem.h:151
FSStatus FSReadDirAsync(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, FSDirectoryEntry *entry, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSGetCwd(FSClient *client, FSCmdBlock *block, char *buffer, uint32_t bufferSize, uint32_t flags)
uint32_t FSGetClientNum()
FSStatus FSSetPosFileAsync(FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t pos, uint32_t flags, FSAsyncData *asyncData)
FSVolumeState FSGetVolumeState(FSClient *client)
FSStatus FSChangeDir(FSClient *client, FSCmdBlock *block, const char *path, uint32_t flags)
uint32_t FSPriority
Definition: filesystem.h:23
FSStatus FSGetStat(FSClient *client, FSCmdBlock *block, const char *path, FSStat *stat, uint32_t flags)
FSStatus FSDelClient(FSClient *client, uint32_t flags)
void FSInitCmdBlock(FSCmdBlock *block)
FSStatus FSGetPosFile(FSClient *client, FSCmdBlock *block, FSFileHandle fileHandle, uint32_t *pos, uint32_t flags)
FSStatus FSReadFile(FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, uint32_t flags)
FSStatus FSOpenDirAsync(FSClient *client, FSCmdBlock *block, const char *path, FSDirectoryHandle *handle, uint32_t flags, FSAsyncData *asyncData)
FSStatFlags flags
Definition: filesystem.h:133
FSStatus FSChangeDirAsync(FSClient *client, FSCmdBlock *block, const char *path, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSGetStatAsync(FSClient *client, FSCmdBlock *block, const char *path, FSStat *stat, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSSetPosFile(FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t pos, uint32_t flags)
FSVolumeState
Definition: filesystem.h:101
FSStatus FSCloseFileAsync(FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSCloseFile(FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t flags)
void(* FSAsyncCallback)(FSClient *, FSCmdBlock *, FSStatus, uint32_t)
Definition: filesystem.h:117
FSStatus FSReadFileWithPosAsync(FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, uint32_t pos, FSFileHandle handle, uint32_t unk1, uint32_t flags, FSAsyncData *asyncData)
void FSInit()
FSStatus
Definition: filesystem.h:32
FSStatFlags
Definition: filesystem.h:96
uint32_t FSFileHandle
Definition: filesystem.h:22
FSStatus FSOpenFile(FSClient *client, FSCmdBlock *block, const char *path, const char *mode, FSFileHandle *handle, uint32_t flags)
FSError FSGetLastErrorCodeForViewer(FSClient *client)
char name[256]
Definition: filesystem.h:161
FSStatus FSReadFileAsync(FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSAddClient(FSClient *client, uint32_t flags)
uint32_t size
Definition: filesystem.h:135
FSStatus FSOpenFileAsync(FSClient *client, FSCmdBlock *block, const char *path, const char *mode, FSFileHandle *outHandle, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSCloseDirAsync(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, uint32_t flags, FSAsyncData *asyncData)
Definition: filesystem.h:158
FSStatus FSReadDir(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, FSDirectoryEntry *entry, uint32_t flags)
FSError
Definition: filesystem.h:55
uint32_t FSDirectoryHandle
Definition: filesystem.h:21
FSStatus FSGetStatFile(FSClient *client, FSCmdBlock *block, FSFileHandle handle, FSStat *stat, uint32_t flags)
void FSSetStateChangeNotification(FSClient *client, FSStateChangeInfo *info)
FSStat info
Definition: filesystem.h:160
void FSShutdown()
FSStatus FSOpenDir(FSClient *client, FSCmdBlock *block, const char *path, FSDirectoryHandle *handle, uint32_t flags)
uint32_t callback
Definition: filesystem.h:150
FSStatus FSGetStatFileAsync(FSClient *client, FSCmdBlock *block, FSFileHandle handle, FSStat *stat, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSReadFileWithPos(FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, uint32_t pos, FSFileHandle handle, uint32_t unk1, uint32_t flags)