WUT  0.1
Wii U Toolchain
filesystem.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 typedef uint32_t FSDirectoryHandle;
25 typedef uint32_t FSFileHandle;
26 typedef uint32_t FSPriority;
27 
28 typedef struct FSAsyncData FSAsyncData;
29 typedef struct FSCmdBlock FSCmdBlock;
30 typedef struct FSClient FSClient;
32 typedef struct FSStat FSStat;
35 
36 typedef enum FSStatus
37 {
57 } FSStatus;
58 
59 typedef enum FSError
60 {
61  FS_ERROR_NOT_INIT = -0x30001,
62  FS_ERROR_BUSY = -0x30002,
63  FS_ERROR_CANCELLED = -0x30003,
64  FS_ERROR_END_OF_DIR = -0x30004,
69  FS_ERROR_MAX_FILES = -0x30013,
70  FS_ERROR_MAX_DIRS = -0x30014,
73  FS_ERROR_NOT_FOUND = -0x30017,
74  FS_ERROR_NOT_EMPTY = -0x30018,
89  FS_ERROR_NOT_FILE = -0x30028,
90  FS_ERROR_NOT_DIR = -0x30029,
98 } FSError;
99 
100 typedef enum FSMode
101 {
105 
109 
113 } FSMode;
114 
115 typedef enum FSStatFlags
116 {
117  FS_STAT_DIRECTORY = 0x80000000,
118 } FSStatFlags;
119 
120 typedef enum FSVolumeState
121 {
134 } FSVolumeState;
135 
136 typedef enum FSMountSourceType
137 {
141 
142 typedef void(*FSAsyncCallback)(FSClient *, FSCmdBlock *, FSStatus, uint32_t);
143 
144 struct FSClient
145 {
146  UNKNOWN(0x1700);
147 };
148 CHECK_SIZE(FSClient, 0x1700);
149 
150 struct FSCmdBlock
151 {
152  UNKNOWN(0xA80);
153 };
154 CHECK_SIZE(FSCmdBlock, 0xA80);
155 
156 struct FSStat
157 {
160  uint32_t owner;
161  uint32_t group;
162  uint32_t size;
163  UNKNOWN(0x50);
164 };
165 CHECK_OFFSET(FSStat, 0x00, flags);
166 CHECK_OFFSET(FSStat, 0x10, size);
167 CHECK_SIZE(FSStat, 0x64);
168 
170 {
171  UNKNOWN(0xC);
172 };
173 CHECK_SIZE(FSStateChangeInfo, 0xC);
174 
176 {
177  uint32_t callback;
178  uint32_t param;
179  UNKNOWN(4);
180 };
181 CHECK_OFFSET(FSAsyncData, 0x0, callback);
182 CHECK_OFFSET(FSAsyncData, 0x4, param);
183 CHECK_SIZE(FSAsyncData, 0xC);
184 
186 {
188  char name[256];
189 };
190 CHECK_OFFSET(FSDirectoryEntry, 0x64, name);
191 CHECK_SIZE(FSDirectoryEntry, 0x164);
192 
194 {
195  UNKNOWN(0x300);
196 };
197 CHECK_SIZE(FSMountSource, 0x300);
198 
199 FSStatus
200 fsDevInit();
201 
202 FSStatus
203 fsDevExit();
204 
205 void
206 FSInit();
207 
208 void
209 FSShutdown();
210 
211 FSStatus
212 FSAddClient(FSClient *client,
213  uint32_t flags);
214 
215 FSStatus
216 FSDelClient(FSClient *client,
217  uint32_t flags);
218 
219 uint32_t
221 
222 void
223 FSInitCmdBlock(FSCmdBlock *block);
224 
225 FSStatus
226 FSSetCmdPriority(FSCmdBlock *block,
227  FSPriority priority);
228 
229 void
230 FSSetStateChangeNotification(FSClient *client,
231  FSStateChangeInfo *info);
232 
233 FSStatus
234 FSGetCwd(FSClient *client,
235  FSCmdBlock *block,
236  char *buffer,
237  uint32_t bufferSize,
238  uint32_t flags);
239 
240 FSStatus
241 FSChangeDir(FSClient *client,
242  FSCmdBlock *block,
243  const char *path,
244  uint32_t flags);
245 
246 FSStatus
247 FSChangeDirAsync(FSClient *client,
248  FSCmdBlock *block,
249  const char *path,
250  uint32_t flags,
251  FSAsyncData *asyncData);
252 
253 FSStatus
254 FSGetStat(FSClient *client,
255  FSCmdBlock *block,
256  const char *path,
257  FSStat *stat,
258  uint32_t flags);
259 
260 FSStatus
261 FSGetStatAsync(FSClient *client,
262  FSCmdBlock *block,
263  const char *path,
264  FSStat *stat,
265  uint32_t flags,
266  FSAsyncData *asyncData);
267 
268 FSStatus
269 FSRemove(FSClient *client,
270  FSCmdBlock *block,
271  const char *path,
272  uint32_t flags);
273 
274 FSStatus
275 FSRemoveAsync(FSClient *client,
276  FSCmdBlock *block,
277  const char *path,
278  uint32_t flags,
279  FSAsyncData *asyncData);
280 
281 
282 FSStatus
283 FSOpenFile(FSClient *client,
284  FSCmdBlock *block,
285  const char *path,
286  const char *mode,
287  FSFileHandle *handle,
288  uint32_t flags);
289 
290 FSStatus
291 FSOpenFileAsync(FSClient *client,
292  FSCmdBlock *block,
293  const char *path,
294  const char *mode,
295  FSFileHandle *outHandle,
296  uint32_t flags,
297  FSAsyncData *asyncData);
298 
299 FSStatus
300 FSCloseFile(FSClient *client,
301  FSCmdBlock *block,
302  FSFileHandle handle,
303  uint32_t flags);
304 
305 FSStatus
306 FSCloseFileAsync(FSClient *client,
307  FSCmdBlock *block,
308  FSFileHandle handle,
309  uint32_t flags,
310  FSAsyncData *asyncData);
311 
312 FSStatus
313 FSOpenDir(FSClient *client,
314  FSCmdBlock *block,
315  const char *path,
316  FSDirectoryHandle *handle,
317  uint32_t flags);
318 
319 FSStatus
320 FSOpenDirAsync(FSClient *client,
321  FSCmdBlock *block,
322  const char *path,
323  FSDirectoryHandle *handle,
324  uint32_t flags,
325  FSAsyncData *asyncData);
326 
327 FSStatus
328 FSMakeDir(FSClient *client,
329  FSCmdBlock *block,
330  const char *path,
331  uint32_t flags);
332 
333 FSStatus
334 FSMakeDirAsync(FSClient *client,
335  FSCmdBlock *block,
336  const char *path,
337  uint32_t flags,
338  FSAsyncData *asyncData);
339 
340 FSStatus
341 FSReadDir(FSClient *client,
342  FSCmdBlock *block,
343  FSDirectoryHandle handle,
344  FSDirectoryEntry *entry,
345  uint32_t flags);
346 
347 FSStatus
348 FSReadDirAsync(FSClient *client,
349  FSCmdBlock *block,
350  FSDirectoryHandle handle,
351  FSDirectoryEntry *entry,
352  uint32_t flags,
353  FSAsyncData *asyncData);
354 
355 FSStatus
356 FSRewindDir(FSClient *client,
357  FSCmdBlock *block,
358  FSDirectoryHandle handle,
359  uint32_t flags);
360 
361 FSStatus
362 FSCloseDir(FSClient *client,
363  FSCmdBlock *block,
364  FSDirectoryHandle handle,
365  uint32_t flags);
366 
367 FSStatus
368 FSCloseDirAsync(FSClient *client,
369  FSCmdBlock *block,
370  FSDirectoryHandle handle,
371  uint32_t flags,
372  FSAsyncData *asyncData);
373 FSStatus
374 FSChangeMode(FSClient *client,
375  FSCmdBlock *block,
376  char *path,
377  FSMode mode,
378  uint32_t flags);
379 
380 FSStatus
381 FSChangeModeAsync(FSClient *client,
382  FSCmdBlock *block,
383  char *path,
384  FSMode mode,
385  uint32_t flags,
386  FSAsyncData *asyncData);
387 
388 FSStatus
389 FSGetFreeSpaceSize(FSClient *client,
390  FSCmdBlock *block,
391  char *path,
392  u64 *outSize,
393  uint32_t flags);
394 
395 FSStatus
396 FSGetFreeSpaceSizeAsync(FSClient *client,
397  FSCmdBlock *block,
398  char *path,
399  u64 *outSize,
400  uint32_t flags,
401  FSAsyncData *asyncData);
402 
403 FSStatus
404 FSGetStatFile(FSClient *client,
405  FSCmdBlock *block,
406  FSFileHandle handle,
407  FSStat *stat,
408  uint32_t flags);
409 
410 FSStatus
411 FSGetStatFileAsync(FSClient *client,
412  FSCmdBlock *block,
413  FSFileHandle handle,
414  FSStat *stat,
415  uint32_t flags,
416  FSAsyncData *asyncData);
417 
418 FSStatus
419 FSReadFile(FSClient *client,
420  FSCmdBlock *block,
421  uint8_t *buffer,
422  uint32_t size,
423  uint32_t count,
424  FSFileHandle handle,
425  uint32_t unk1,
426  uint32_t flags);
427 
428 FSStatus
429 FSReadFileAsync(FSClient *client,
430  FSCmdBlock *block,
431  uint8_t *buffer,
432  uint32_t size,
433  uint32_t count,
434  FSFileHandle handle,
435  uint32_t unk1,
436  uint32_t flags,
437  FSAsyncData *asyncData);
438 
439 FSStatus
440 FSReadFileWithPos(FSClient *client,
441  FSCmdBlock *block,
442  uint8_t *buffer,
443  uint32_t size,
444  uint32_t count,
445  uint32_t pos,
446  FSFileHandle handle,
447  uint32_t unk1,
448  uint32_t flags);
449 
450 FSStatus
451 FSReadFileWithPosAsync(FSClient *client,
452  FSCmdBlock *block,
453  uint8_t *buffer,
454  uint32_t size,
455  uint32_t count,
456  uint32_t pos,
457  FSFileHandle handle,
458  uint32_t unk1,
459  uint32_t flags,
460  FSAsyncData *asyncData);
461 
462 FSStatus
463 FSWriteFile(FSClient *client,
464  FSCmdBlock *block,
465  uint8_t *buffer,
466  uint32_t size,
467  uint32_t count,
468  FSFileHandle handle,
469  uint32_t unk1,
470  uint32_t flags);
471 
472 FSStatus
473 FSWriteFileAsync(FSClient *client,
474  FSCmdBlock *block,
475  uint8_t *buffer,
476  uint32_t size,
477  uint32_t count,
478  FSFileHandle handle,
479  uint32_t unk1,
480  uint32_t flags,
481  FSAsyncData *asyncData);
482 
483 FSStatus
484 FSWriteFileWithPos(FSClient *client,
485  FSCmdBlock *block,
486  uint8_t *buffer,
487  uint32_t size,
488  uint32_t count,
489  uint32_t pos,
490  FSFileHandle handle,
491  uint32_t unk1,
492  uint32_t flags);
493 
494 FSStatus
495 FSWriteFileWithPosAsync(FSClient *client,
496  FSCmdBlock *block,
497  uint8_t *buffer,
498  uint32_t size,
499  uint32_t count,
500  uint32_t pos,
501  FSFileHandle handle,
502  uint32_t unk1,
503  uint32_t flags,
504  FSAsyncData *asyncData);
505 
506 FSStatus
507 FSGetPosFile(FSClient *client,
508  FSCmdBlock *block,
509  FSFileHandle fileHandle,
510  uint32_t *pos,
511  uint32_t flags);
512 
513 FSStatus
514 FSGetPosFileAsync(FSClient *client,
515  FSCmdBlock *block,
516  FSFileHandle fileHandle,
517  uint32_t *pos,
518  uint32_t flags,
519  FSAsyncData *asyncData);
520 
521 FSStatus
522 FSSetPosFile(FSClient *client,
523  FSCmdBlock *block,
524  FSFileHandle handle,
525  uint32_t pos,
526  uint32_t flags);
527 
528 FSStatus
529 FSSetPosFileAsync(FSClient *client,
530  FSCmdBlock *block,
531  FSFileHandle handle,
532  uint32_t pos,
533  uint32_t flags,
534  FSAsyncData *asyncData);
535 
536 FSStatus
537 FSFlushFile(FSClient *client,
538  FSCmdBlock *block,
539  FSFileHandle handle,
540  uint32_t flags);
541 
542 FSStatus
543 FSFlushFileAsync(FSClient *client,
544  FSCmdBlock *block,
545  FSFileHandle handle,
546  uint32_t flags,
547  FSAsyncData *asyncData);
548 
549 FSStatus
550 FSTruncateFile(FSClient *client,
551  FSCmdBlock *block,
552  FSFileHandle handle,
553  uint32_t flags);
554 
555 FSStatus
556 FSTruncateFileAsync(FSClient *client,
557  FSCmdBlock *block,
558  FSFileHandle handle,
559  uint32_t flags,
560  FSAsyncData *asyncData);
561 
562 FSStatus
563 FSRename(FSClient *client,
564  FSCmdBlock *block,
565  const char *oldPath,
566  const char *newPath,
567  uint32_t flags);
568 
569 FSStatus
570 FSRenameAsync(FSClient *client,
571  FSCmdBlock *block,
572  const char *oldPath,
573  const char *newPath,
574  uint32_t flags,
575  FSAsyncData *asyncData);
576 
578 FSGetVolumeState(FSClient *client);
579 
580 FSError
581 FSGetLastErrorCodeForViewer(FSClient *client);
582 
583 FSStatus
584 FSGetMountSource(FSClient *client,
585  FSCmdBlock *cmd,
586  FSMountSourceType type,
587  FSMountSource *out,
588  uint32_t flags);
589 
590 FSStatus
591 FSMount(FSClient *client,
592  FSCmdBlock *cmd,
593  FSMountSource *source,
594  const char *target,
595  uint32_t bytes,
596  uint32_t flags);
597 
598 FSStatus
599 FSUnmount(FSClient *client,
600  FSCmdBlock *cmd,
601  const char *target,
602  uint32_t flags);
603 
604 FSStatus
605 FSBindMount(FSClient *client,
606  FSCmdBlock *cmd,
607  const char *source,
608  const char *target,
609  uint32_t flags);
610 
611 FSStatus
612 FSbindUnmount(FSClient *client,
613  FSCmdBlock *cmd,
614  const char *target,
615  uint32_t flags);
616 
617 #ifdef __cplusplus
618 }
619 #endif
620 
FSMode mode
Definition: filesystem.h:159
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 FSMakeDirAsync(FSClient *client, FSCmdBlock *block, const char *path, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSSetCmdPriority(FSCmdBlock *block, FSPriority priority)
uint32_t param
Definition: filesystem.h:178
FSStatus FSReadDirAsync(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, FSDirectoryEntry *entry, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSMakeDir(FSClient *client, FSCmdBlock *block, const char *path, uint32_t flags)
FSStatus fsDevExit()
FSMode
Definition: filesystem.h:100
FSStatus FSGetCwd(FSClient *client, FSCmdBlock *block, char *buffer, uint32_t bufferSize, uint32_t flags)
FSStatus FSMount(FSClient *client, FSCmdBlock *cmd, FSMountSource *source, const char *target, uint32_t bytes, uint32_t flags)
uint32_t FSGetClientNum()
FSStatus FSbindUnmount(FSClient *client, FSCmdBlock *cmd, const char *target, uint32_t flags)
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:26
FSStatus FSGetStat(FSClient *client, FSCmdBlock *block, const char *path, FSStat *stat, uint32_t flags)
FSStatus FSDelClient(FSClient *client, uint32_t flags)
FSStatus FSWriteFileWithPos(FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, uint32_t pos, FSFileHandle handle, uint32_t unk1, uint32_t flags)
void FSInitCmdBlock(FSCmdBlock *block)
FSStatus FSGetPosFile(FSClient *client, FSCmdBlock *block, FSFileHandle fileHandle, uint32_t *pos, uint32_t flags)
uint32_t owner
Definition: filesystem.h:160
FSMountSourceType
Definition: filesystem.h:136
FSStatus FSRename(FSClient *client, FSCmdBlock *block, const char *oldPath, const char *newPath, 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:158
FSStatus FSChangeDirAsync(FSClient *client, FSCmdBlock *block, const char *path, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSWriteFileWithPosAsync(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)
FSStatus FSChangeModeAsync(FSClient *client, FSCmdBlock *block, char *path, FSMode mode, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSGetStatAsync(FSClient *client, FSCmdBlock *block, const char *path, FSStat *stat, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSFlushFile(FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t flags)
FSStatus FSBindMount(FSClient *client, FSCmdBlock *cmd, const char *source, const char *target, uint32_t flags)
FSStatus FSSetPosFile(FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t pos, uint32_t flags)
FSVolumeState
Definition: filesystem.h:120
FSStatus FSRenameAsync(FSClient *client, FSCmdBlock *block, const char *oldPath, const char *newPath, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSCloseFileAsync(FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSTruncateFileAsync(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:142
FSStatus FSRewindDir(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, uint32_t flags)
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)
FSStatus FSGetFreeSpaceSize(FSClient *client, FSCmdBlock *block, char *path, u64 *outSize, uint32_t flags)
FSStatus FSUnmount(FSClient *client, FSCmdBlock *cmd, const char *target, uint32_t flags)
void FSInit()
FSStatus fsDevInit()
FSStatus
Definition: filesystem.h:36
FSStatFlags
Definition: filesystem.h:115
uint32_t FSFileHandle
Definition: filesystem.h:25
FSStatus FSOpenFile(FSClient *client, FSCmdBlock *block, const char *path, const char *mode, FSFileHandle *handle, uint32_t flags)
FSError FSGetLastErrorCodeForViewer(FSClient *client)
FSStatus FSChangeMode(FSClient *client, FSCmdBlock *block, char *path, FSMode mode, uint32_t flags)
uint64_t u64
Definition: wut_types.h:18
char name[256]
Definition: filesystem.h:188
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:162
FSStatus FSGetFreeSpaceSizeAsync(FSClient *client, FSCmdBlock *block, char *path, u64 *outSize, uint32_t flags, FSAsyncData *asyncData)
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)
uint32_t group
Definition: filesystem.h:161
Definition: filesystem.h:185
FSStatus FSReadDir(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, FSDirectoryEntry *entry, uint32_t flags)
FSError
Definition: filesystem.h:59
FSStatus FSGetMountSource(FSClient *client, FSCmdBlock *cmd, FSMountSourceType type, FSMountSource *out, uint32_t flags)
uint32_t FSDirectoryHandle
Definition: filesystem.h:24
FSStatus FSFlushFileAsync(FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSGetStatFile(FSClient *client, FSCmdBlock *block, FSFileHandle handle, FSStat *stat, uint32_t flags)
FSStatus FSWriteFileAsync(FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, uint32_t flags, FSAsyncData *asyncData)
FSStatus FSRemove(FSClient *client, FSCmdBlock *block, const char *path, uint32_t flags)
void FSSetStateChangeNotification(FSClient *client, FSStateChangeInfo *info)
FSStat info
Definition: filesystem.h:187
void FSShutdown()
FSStatus FSWriteFile(FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, uint32_t flags)
FSStatus FSTruncateFile(FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t flags)
FSStatus FSOpenDir(FSClient *client, FSCmdBlock *block, const char *path, FSDirectoryHandle *handle, uint32_t flags)
uint32_t callback
Definition: filesystem.h:177
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)
FSStatus FSRemoveAsync(FSClient *client, FSCmdBlock *block, const char *path, uint32_t flags, FSAsyncData *asyncData)