1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
#ifndef _DOLCESDK_PSP2_KERNEL_IOFILEMGR_H_
#define _DOLCESDK_PSP2_KERNEL_IOFILEMGR_H_
#include <psp2common/kernel/iofilemgr.h>
#include <psp2/kernel/iofilemgr/async.h>
#include <psp2/kernel/iofilemgr/stat.h>
#include <psp2/kernel/iofilemgr/dirent.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Remove directory entry
*
* @param filename - Path to the file to remove
* @return < 0 on error
*/
int sceIoRemove(const char *filename);
/**
* Make a directory file
*
* @param dirname - The path to the directory
* @param mode - Access mode bits.
* @return Returns the value 0 if it's successful, otherwise <0
*/
int sceIoMkdir(const char *dirname, SceIoMode mode);
/**
* Remove a directory file
*
* @param dirname - Removes a directory file pointed by the string path
* @return Returns the value 0 if it's successful, otherwise <0
*/
int sceIoRmdir(const char *dirname);
/**
* Change the name of a file
*
* @param oldname - The old filename
* @param newname - The new filename
* @return < 0 on error.
*/
int sceIoRename(const char *oldname, const char *newname);
/**
* Send a devctl command to a device.
*
* @par Example: Sending a simple command to a device
* @code
* SceIoDevInfo info;
* sceIoDevctl("ux0:", 0x3001, NULL, 0, &info, sizeof(SceIoDevInfo));
* @endcode
*
* @param devname - String for the device to send the devctl to (e.g. "ux0:")
* @param cmd - The command to send to the device
* @param arg - A data block to send to the device, if NULL sends no data
* @param arglen - Length of indata, if 0 sends no data
* @param bufp - A data block to receive the result of a command, if NULL receives no data
* @param buflen - Length of outdata, if 0 receives no data
* @return 0 on success, < 0 on error
*/
int sceIoDevctl(
const char *devname,
int cmd,
const void *arg,
SceSize arglen,
void *bufp,
SceSize buflen);
/**
* Synchronize the file data on the device.
*
* @param devname - The device to synchronize (e.g. msfat0:)
* @param flag - device specific flags
*/
int sceIoSync(const char *devname, int flag);
/**
* Open or create a file for reading or writing
*
* @par Example1: Open a file for reading
* @code
* if((fd = sceIoOpen("device:/path/to/file", SCE_O_RDONLY, 0777) < 0) {
* // error code in fd, for example no open filehandle left (0x80010018)
* }
* @endcode
* @par Example2: Open a file for writing, creating it if it doesn't exist
* @code
* if((fd = sceIoOpen("device:/path/to/file", SCE_O_WRONLY|SCE_O_CREAT, 0777) < 0) {
* // error code in fd, for example no open filehandle left (0x80010018)
* }
* @endcode
*
* @param filename - Pointer to a string holding the name of the file to open
* @param flag - Libc styled flags that are or'ed together
* @param mode - File access mode (One or more ::SceIoMode).
* @return A non-negative integer is a valid fd, anything else an error
*/
SceUID sceIoOpen(const char *filename, int flag, SceIoMode mode);
/**
* Delete a descriptor
*
* @code
* sceIoClose(fd);
* @endcode
*
* @param fd - File descriptor to close
* @return < 0 on error
*/
int sceIoClose(SceUID fd);
/**
* Perform an ioctl on a device.
*
* @param fd - Opened file descriptor to ioctl to
* @param cmd - The command to send to the device
* @param argp - A data block to send to the device, if NULL sends no data
* @param arglen - Length of indata, if 0 sends no data
* @param bufp - A data block to receive the result of a command, if NULL receives no data
* @param buflen - Length of outdata, if 0 receives no data
* @return 0 on success, < 0 on error
*/
int sceIoIoctl(
SceUID fd,
int cmd,
const void *argp,
SceSize arglen,
void *bufp,
SceSize buflen);
/**
* Reposition read/write file descriptor offset
*
* @par Example:
* @code
* pos = sceIoLseek(fd, -10, SCE_SEEK_END);
* @endcode
*
* @param fd - Opened file descriptor with which to seek
* @param offset - Relative offset from the start position given by whence
* @param whence - One of ::SceIoSeekMode.
*
* @return The position in the file after the seek.
*/
SceOff sceIoLseek(SceUID fd, SceOff offset, int whence);
/**
* Reposition read/write file descriptor offset (32bit mode)
*
* @par Example:
* @code
* pos = sceIoLseek32(fd, -10, SCE_SEEK_END);
* @endcode
*
* @param fd - Opened file descriptor with which to seek
* @param offset - Relative offset from the start position given by whence
* @param whence - One of ::SceIoSeekMode.
*
* @return The position in the file after the seek.
*/
long sceIoLseek32(SceUID fd, long offset, int whence);
/**
* Read input
*
* @par Example:
* @code
* bytes_read = sceIoRead(fd, data, 100);
* @endcode
*
* @param fd - Opened file descriptor to read from
* @param buf - Pointer to the buffer where the read data will be placed
* @param nbyte - Size of the read in bytes
*
* @return The number of bytes read
*/
SceSSize sceIoRead(SceUID fd, void *buf, SceSize nbyte);
/**
* Write output
*
* @par Example:
* @code
* bytes_written = sceIoWrite(fd, data, 100);
* @endcode
*
* @param fd - Opened file descriptor to write to
* @param buf - Pointer to the data to write
* @param nbyte - Size of data to write
*
* @return The number of bytes written
*/
SceSSize sceIoWrite(SceUID fd, const void *buf, SceSize nbyte);
/**
* Read input at offset
*
* @par Example:
* @code
* bytes_read = sceIoPread(fd, data, 100, 0x1000);
* @endcode
*
* @param fd - Opened file descriptor to read from
* @param buf - Pointer to the buffer where the read data will be placed
* @param nbyte - Size of the read in bytes
* @param offset - Offset to read
*
* @return < 0 on error.
*/
SceSSize sceIoPread(SceUID fd, void *buf, SceSize nbyte, SceOff offset);
/**
* Write output at offset
*
* @par Example:
* @code
* bytes_written = sceIoPwrite(fd, data, 100, 0x1000);
* @endcode
*
* @param fd - Opened file descriptor to write to
* @param buf - Pointer to the data to write
* @param nbyte - Size of data to write
* @param offset - Offset to write
*
* @return The number of bytes written
*/
SceSSize sceIoPwrite(SceUID fd, const void *buf, SceSize nbyte, SceOff offset);
/**
* Synchronize the file data for one file
*
* @param fd - Opened file descriptor to sync
* @param flag - device specific flags
*
* @return < 0 on error.
*/
int sceIoSyncByFd(SceUID fd, int flag);
/*--------------------Async IO--------------------*/
/**
* Remove directory entry (asynchronous)
*
* @param file - Path to the file to remove
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
int sceIoRemoveAsync(const char *file, SceIoAsyncParam* asyncParam);
/**
* Change the name of a file (asynchronous)
*
* @param oldname - The old filename
* @param newname - The new filename
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoRenameAsync(const char *oldname, const char *newname, SceIoAsyncParam* asyncParam);
/**
* Open or create a file for reading or writing (asynchronous)
*
* @param file - Pointer to a string holding the name of the file to open
* @param flags - Libc styled flags that are or'ed together
* @param mode - File access mode (One or more ::SceIoMode).
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoOpenAsync(const char *file, int flags, SceMode mode, SceIoAsyncParam* asyncParam);
/**
* Delete a descriptor (asynchronous)
*
* @param fd - File descriptor to close
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoCloseAsync(SceUID fd, SceIoAsyncParam* asyncParam);
/**
* Read input (asynchronous)
*
* @param fd - Opened file descriptor to read from
* @param data - Pointer to the buffer where the read data will be placed
* @param size - Size of the read in bytes
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoReadAsync(SceUID fd, void *data, SceSize size, SceIoAsyncParam* asyncParam);
/**
* Read input at offset (asynchronous)
*
* @param fd - Opened file descriptor to read from
* @param data - Pointer to the buffer where the read data will be placed
* @param size - Size of the read in bytes
* @param offset - Offset to read
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoPreadAsync(SceUID fd, void *data, SceSize size, SceOff offset, SceIoAsyncParam* asyncParam);
/**
* Write output (asynchronous)
*
* @param fd - Opened file descriptor to write to
* @param data - Pointer to the data to write
* @param size - Size of data to write
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoWriteAsync(SceUID fd, const void *data, SceSize size, SceIoAsyncParam* asyncParam);
/**
* Write output at offset (asynchronous)
*
* @param fd - Opened file descriptor to write to
* @param data - Pointer to the data to write
* @param size - Size of data to write
* @param offset - Offset to write
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoPwriteAsync(SceUID fd, const void *data, SceSize size, SceOff offset, SceIoAsyncParam* asyncParam);
/**
* Reposition read/write file descriptor offset (asynchronous)
*
* @param fd - Opened file descriptor with which to seek
* @param offset - Relative offset from the start position given by whence
* @param whence - One of ::SceIoSeekMode.
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoLseekAsync(SceUID fd, SceOff offset, int whence, SceIoAsyncParam* asyncParam);
/**
* Synchronize device state with state of file or directory being opened
*
* @param fd - Opened file descriptor to sync
* @param fd - Device-dependent flag
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoSyncByFdAsync(SceUID fd, int flag, SceIoAsyncParam* asyncParam);
/**
* Synchronize device state with memory state
*
* @param fd - Device name
* @param fd - Device-dependent flag
* @param asyncParam - parameters related to async operation.
*
* @return A non-negative integer is a valid op handle, anything else an error
*/
SceUID sceIoSyncAsync(const char* device, int flag, SceIoAsyncParam* asyncParam);
/**
* This function is unimplemented.
*
* @return SCE_KERNEL_ERROR_UNSUP (0x80020004)
*/
int sceIoIoctlAsync(
SceUID fd,
int cmd,
const void *argp,
SceSize arglen,
void *bufp,
SceSize buflen,
SceIoAsyncParam* asyncParam);
/**
* This function is unimplemented.
*
* @return SCE_KERNEL_ERROR_UNSUP (0x80020004)
*/
int sceIoDevctlAsync(
const char *devname,
int cmd,
const void *arg,
SceSize arglen,
void *bufp,
SceSize buflen,
SceIoAsyncParam* asyncParam);
/*--------------------IO Priority--------------------*/
/*Valid priority values range: 1 (highest) - 15 (lowest). Default priority value is 14*/
/**
* Set IO operations priority for file descriptor
*
* @param fd - File UID
* @param priority - IO operations priority
*
* @return < 0 on error.
*/
int sceIoSetPriority(SceUID fd, int priority);
/**
* Set IO operations priority for file descriptor for non-game application
*
* @param fd - File UID
* @param priority - IO operations priority
*
* @return < 0 on error.
*/
int sceIoSetPriorityForSystem(SceUID fd, int priority);
/**
* Get IO operations priority for file descriptor
*
* @param fd - File UID
*
* @return A non-negative integer is a valid priority, anything else an error
*/
int sceIoGetPriority(SceUID fd);
/**
* Get IO operations priority for file descriptor for non-game application
*
* @param fd - File UID
*
* @return A non-negative integer is a valid priority, anything else an error
*/
int sceIoGetPriorityForSystem(SceUID fd);
/**
* Set IO operations priority for caller process (will be default for all new IO operations)
*
* @param priority - New default IO operations priority
*
* @return < 0 on error.
*/
int sceIoSetProcessDefaultPriority(int priority);
/**
* Get IO operations priority for process
*
* @return A non-negative integer is a valid priority, anything else an error
*/
int sceIoGetProcessDefaultPriority(void);
/**
* Set IO operations priority for caller thread (will be default for all new IO operations)
*
* @param priority - New default IO operations priority
*
* @return < 0 on error.
*/
int sceIoSetThreadDefaultPriority(int priority);
/**
* Set IO operations priority for caller thread for non-game
* application (will be default for all new IO operations)
*
* @param priority - New default IO operations priority
*
* @return < 0 on error.
*/
int sceIoSetThreadDefaultPriorityForSystem(int priority);
/**
* Get IO operations priority for thread
*
* @return A non-negative integer is a valid priority, anything else an error
*/
int sceIoGetThreadDefaultPriority(void);
/**
* Get IO operations priority for thread for non-game application
*
* @return A non-negative integer is a valid priority, anything else an error
*/
int sceIoGetThreadDefaultPriorityForSystem(void);
#ifdef __cplusplus
}
#endif
#endif /* _DOLCESDK_PSP2_KERNEL_IOFILEMGR_H_ */
|