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