ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
ps2sdkapi.c
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <stdarg.h>
14 #include <errno.h>
15 #include <string.h>
16 #include <kernel.h>
17 #include <malloc.h>
18 #include <sio.h>
19 
20 #include <time.h>
21 #include <sys/time.h>
22 #include <sys/times.h>
23 #include <sys/stat.h>
24 #include <sys/types.h>
25 
26 // Include all integer types for compile time checking of:
27 // - compiler (gcc)
28 // - libc (newlib)
29 #include <stdint.h>
30 #include <limits.h>
31 #include <inttypes.h>
32 #include <tamtypes.h>
33 
34 #define NEWLIB_PORT_AWARE
35 #include "fileio.h"
36 #include "io_common.h"
37 #include "iox_stat.h"
38 #include "ps2sdkapi.h"
39 
40 
41 extern void *ps2_sbrk(size_t increment);
42 
43 
44 /* the present working directory variable. */
45 char __direct_pwd[256] = "";
46 
47 
48 int fioRename(const char *old, const char *new) {
49  return -ENOSYS;
50 }
51 
52 int fioMkdirHelper(const char *path, int mode) {
53  // Old fio mkdir has no mode argument
54  return fioMkdir(path);
55 }
56 
57 static time_t io_to_posix_time(const unsigned char *ps2time)
58 {
59  struct tm tim;
60  tim.tm_sec = ps2time[1];
61  tim.tm_min = ps2time[2];
62  tim.tm_hour = ps2time[3];
63  tim.tm_mday = ps2time[4];
64  tim.tm_mon = ps2time[5] - 1;
65  tim.tm_year = ((u16)ps2time[6] | ((u16)ps2time[7] << 8)) - 1900;
66  return mktime(&tim);
67 }
68 
69 static mode_t io_to_posix_mode(unsigned int ps2mode)
70 {
71  mode_t posixmode = 0;
72  if (ps2mode & FIO_SO_IFREG) posixmode |= S_IFREG;
73  if (ps2mode & FIO_SO_IFDIR) posixmode |= S_IFDIR;
74  if (ps2mode & FIO_SO_IROTH) posixmode |= S_IRUSR|S_IRGRP|S_IROTH;
75  if (ps2mode & FIO_SO_IWOTH) posixmode |= S_IWUSR|S_IWGRP|S_IWOTH;
76  if (ps2mode & FIO_SO_IXOTH) posixmode |= S_IXUSR|S_IXGRP|S_IXOTH;
77  return posixmode;
78 }
79 
80 static void fill_stat(struct stat *stat, const io_stat_t *fiostat)
81 {
82  stat->st_dev = 0;
83  stat->st_ino = 0;
84  stat->st_mode = io_to_posix_mode(fiostat->mode);
85  stat->st_nlink = 0;
86  stat->st_uid = 0;
87  stat->st_gid = 0;
88  stat->st_rdev = 0;
89  stat->st_size = ((off_t)fiostat->hisize << 32) | (off_t)fiostat->size;
90  stat->st_atime = io_to_posix_time(fiostat->atime);
91  stat->st_mtime = io_to_posix_time(fiostat->mtime);
92  stat->st_ctime = io_to_posix_time(fiostat->ctime);
93  stat->st_blksize = 16*1024;
94  stat->st_blocks = stat->st_size / 512;
95 }
96 
97 static int fioGetstatHelper(const char *path, struct stat *buf) {
98  io_stat_t fiostat;
99 
100  if (fioGetstat(path, &fiostat) < 0) {
101  //errno = ENOENT;
102  return -1;
103  }
104 
105  fill_stat(buf, &fiostat);
106 
107  return 0;
108 }
109 
110 static DIR *fioOpendirHelper(const char *path)
111 {
112  int dd;
113  DIR *dir;
114 
115  dd = fioDopen(path);
116  if (dd < 0) {
117  //errno = ENOENT;
118  return NULL;
119  }
120 
121  dir = malloc(sizeof(DIR));
122  dir->dd_fd = dd;
123  dir->dd_buf = malloc(sizeof(struct dirent));
124 
125  return dir;
126 }
127 
128 static struct dirent *fioReaddirHelper(DIR *dir)
129 {
130  int rv;
131  struct dirent *de;
132  io_dirent_t fiode;
133 
134  if(dir == NULL) {
135  //errno = EBADF;
136  return NULL;
137  }
138 
139  de = (struct dirent *)dir->dd_buf;
140  rv = fioDread(dir->dd_fd, &fiode);
141  if (rv <= 0) {
142  return NULL;
143  }
144 
145  fill_stat(&de->d_stat, &fiode.stat);
146  strncpy(de->d_name, fiode.name, 255);
147  de->d_name[255] = 0;
148 
149  return de;
150 }
151 
152 static void fioRewinddirHelper(DIR *dir)
153 {
154  printf("rewinddir not implemented\n");
155 }
156 
157 static int fioClosedirHelper(DIR *dir)
158 {
159  if(dir == NULL) {
160  //errno = EBADF;
161  return -1;
162  }
163 
164  fioDclose(dir->dd_fd); // Check return value?
165  free(dir->dd_buf);
166  free(dir);
167 
168  return 0;
169 }
170 
171 int (*_ps2sdk_close)(int) = fioClose;
172 int (*_ps2sdk_open)(const char*, int, ...) = (void *)fioOpen;
173 int (*_ps2sdk_read)(int, void*, int) = fioRead;
174 int (*_ps2sdk_lseek)(int, int, int) = fioLseek;
175 int64_t (*_ps2sdk_lseek64)(int, int64_t, int) = NULL;
176 int (*_ps2sdk_write)(int, const void*, int) = fioWrite;
177 int (*_ps2sdk_ioctl)(int, int, void*) = fioIoctl;
178 int (*_ps2sdk_remove)(const char*) = fioRemove;
179 int (*_ps2sdk_rename)(const char*, const char*) = fioRename;
180 int (*_ps2sdk_mkdir)(const char*, int) = fioMkdirHelper;
181 int (*_ps2sdk_rmdir)(const char*) = fioRmdir;
182 
183 int (*_ps2sdk_stat)(const char *path, struct stat *buf) = fioGetstatHelper;
184 
185 DIR * (*_ps2sdk_opendir)(const char *path) = fioOpendirHelper;
186 struct dirent * (*_ps2sdk_readdir)(DIR *dir) = fioReaddirHelper;
189 
190 #define IOP_O_RDONLY 0x0001
191 #define IOP_O_WRONLY 0x0002
192 #define IOP_O_RDWR 0x0003
193 #define IOP_O_DIROPEN 0x0008 // Internal use for dopen
194 #define IOP_O_NBLOCK 0x0010
195 #define IOP_O_APPEND 0x0100
196 #define IOP_O_CREAT 0x0200
197 #define IOP_O_TRUNC 0x0400
198 #define IOP_O_EXCL 0x0800
199 #define IOP_O_NOWAIT 0x8000
200 
201 #if INT_MAX != 0x7fffffffL
202  #error "INT_MAX != 0x7fffffffL"
203 #endif
204 #ifndef LONG_MAX
205  #error "LONG_MAX not defined"
206 #endif
207 #if LONG_MAX != 0x7fffffffL
208  #error "LONG_MAX != 0x7fffffffL"
209 #endif
210 
211 #define ct_assert(e) {enum { ct_assert_value = 1/(!!(e)) };}
213  // Compiler (ABI n32)
214  ct_assert(sizeof(unsigned char)==1);
215  ct_assert(sizeof(unsigned short)==2);
216  ct_assert(sizeof(unsigned int)==4);
217  ct_assert(sizeof(unsigned long)==4);
218  ct_assert(sizeof(unsigned long long)==8);
219  ct_assert(sizeof(unsigned int __attribute__(( mode(TI) )))==16);
220  ct_assert(sizeof(void *)==4);
221 
222  // Defined in tamtypes.h (ps2sdk)
223  ct_assert(sizeof(u8)==1);
224  ct_assert(sizeof(u16)==2);
225  ct_assert(sizeof(u32)==4);
226  ct_assert(sizeof(u64)==8);
227  ct_assert(sizeof(u128)==16);
228 
229  // Defined in inttypes.h/stdint.h (newlib)
230  ct_assert(sizeof(uint8_t)==1);
231  ct_assert(sizeof(uint16_t)==2);
232  ct_assert(sizeof(uint32_t)==4);
233  ct_assert(sizeof(uint64_t)==8);
234 }
235 
236 /* Normalize a pathname by removing . and .. components, duplicated /, etc. */
237 static char* normalize_path(const char *path_name)
238 {
239  int i, j;
240  int first, next;
241  static char out[255];
242 
243  /* First copy the path into our temp buffer */
244  strcpy(out, path_name);
245  /* Then append "/" to make the rest easier */
246  strcat(out,"/");
247 
248  /* Convert "//" to "/" */
249  for(i=0; out[i+1]; i++) {
250  if(out[i]=='/' && out[i+1]=='/') {
251  for(j=i+1; out[j]; j++)
252  out[j] = out[j+1];
253  i--;
254  ;}
255  }
256 
257  /* Convert "/./" to "/" */
258  for(i=0; out[i] && out[i+1] && out[i+2]; i++) {
259  if(out[i]=='/' && out[i+1]=='.' && out[i+2]=='/') {
260  for(j=i+1; out[j]; j++)
261  out[j] = out[j+2];
262  i--;
263  }
264  }
265 
266  /* Convert "/path/../" to "/" until we can't anymore. Also convert leading
267  * "/../" to "/" */
268  first = next = 0;
269  while(1) {
270  /* If a "../" follows, remove it and the parent */
271  if(out[next+1] && out[next+1]=='.' &&
272  out[next+2] && out[next+2]=='.' &&
273  out[next+3] && out[next+3]=='/') {
274  for(j=0; out[first+j+1]; j++)
275  out[first+j+1] = out[next+j+4];
276  first = next = 0;
277  continue;
278  }
279 
280  /* Find next slash */
281  first = next;
282  for(next=first+1; out[next] && out[next] != '/'; next++)
283  continue;
284  if(!out[next]) break;
285  }
286 
287  /* Remove trailing "/" */
288  for(i=1; out[i]; i++)
289  continue;
290  if(i >= 1 && out[i-1] == '/')
291  out[i-1] = 0;
292 
293  return (char*)out;
294 }
295 
296 static int isCdromPath(const char *path)
297 {
298  return !strncmp(path, "cdrom0:", 7) || !strncmp(path, "cdrom:", 6);
299 }
300 
301 int _open(const char *buf, int flags, ...) {
302  int iop_flags = 0;
303 
304  // newlib frags differ from iop flags
305  if ((flags & 3) == O_RDONLY) iop_flags |= IOP_O_RDONLY;
306  if ((flags & 3) == O_WRONLY) iop_flags |= IOP_O_WRONLY;
307  if ((flags & 3) == O_RDWR ) iop_flags |= IOP_O_RDWR;
308  if (flags & O_NONBLOCK) iop_flags |= IOP_O_NBLOCK;
309  if (flags & O_APPEND) iop_flags |= IOP_O_APPEND;
310  if (flags & O_CREAT) iop_flags |= IOP_O_CREAT;
311  if (flags & O_TRUNC) iop_flags |= IOP_O_TRUNC;
312  if (flags & O_EXCL) iop_flags |= IOP_O_EXCL;
313  //if (flags & O_???) iop_flags |= IOP_O_NOWAIT;
314 
315  char *t_fname = normalize_path(buf);
316  char b_fname[FILENAME_MAX];
317 
318  if (!strchr(buf, ':')) { // filename doesn't contain device
319  t_fname = b_fname;
320  if (buf[0] == '/' || buf[0] == '\\') { // does it contain root ?
321  char *device_end = strchr(__direct_pwd, ':');
322  if (device_end) { // yes, let's strip pwd a bit to keep device only
323  strncpy(b_fname, __direct_pwd, device_end - __direct_pwd);
324  strcpy(b_fname + (device_end - __direct_pwd), buf);
325  } else { // but pwd doesn't contain any device, let's default to host
326  strcpy(b_fname, "host:");
327  strcpy(b_fname + 5, buf);
328  }
329  } else { // otherwise, it's relative directory, let's copy pwd straight
330  int b_fname_len = strlen(__direct_pwd);
331  if (!strchr(__direct_pwd, ':')) { // check if pwd contains device name
332  strcpy(b_fname, "host:");
333  strcpy(b_fname + 5, __direct_pwd);
334  if (!(__direct_pwd[b_fname_len - 1] == '/' || __direct_pwd[b_fname_len - 1] == '\\')) { // does it has trailing slash ?
335  if(isCdromPath(b_fname)) {
336  b_fname[b_fname_len + 5] = '\\';
337  b_fname_len++;
338  } else {
339  b_fname[b_fname_len + 5] = '/';
340  b_fname_len++;
341  }
342  }
343  b_fname_len += 5;
344  strcpy(b_fname + b_fname_len, buf);
345  } else { // device name is here
346  if (b_fname_len) {
347  strcpy(b_fname, __direct_pwd);
348  if (!(b_fname[b_fname_len - 1] == '/' || b_fname[b_fname_len - 1] == '\\')) {
349  if(isCdromPath(b_fname)) {
350  b_fname[b_fname_len] = '\\';
351  b_fname_len++;
352  } else {
353  b_fname[b_fname_len] = '/';
354  b_fname_len++;
355  }
356  }
357  strcpy(b_fname + b_fname_len, buf);
358  }
359  }
360  }
361  }
362 
363  return _ps2sdk_open(t_fname, iop_flags);
364 }
365 
366 int _close(int fd) {
367  return _ps2sdk_close(fd);
368 }
369 
370 int _read(int fd, void *buf, size_t nbytes) {
371  return _ps2sdk_read(fd, buf, nbytes);
372 }
373 
374 int _write(int fd, const void *buf, size_t nbytes) {
375  // HACK: stdout and strerr to serial
376  //if ((fd==1) || (fd==2))
377  // return sio_write((void *)buf, nbytes);
378 
379  return _ps2sdk_write(fd, buf, nbytes);
380 }
381 
382 int _fstat(int fd, struct stat *buf) {
383  if (fd >=0 && fd <= 1) {
384  // Character device
385  buf->st_mode = S_IFCHR;
386  buf->st_blksize = 0;
387  }
388  else {
389  // Block device
390  buf->st_mode = S_IFBLK;
391  buf->st_blksize = 16*1024;
392  }
393 
394  return 0;
395 }
396 
397 int _stat(const char *path, struct stat *buf) {
398  return _ps2sdk_stat(path, buf);
399 }
400 
401 int access(const char *fn, int flags) {
402  struct stat s;
403  if (stat(fn, &s))
404  return -1;
405  if (s.st_mode & S_IFDIR)
406  return 0;
407  if (flags & W_OK) {
408  if (s.st_mode & S_IWRITE)
409  return 0;
410  return -1;
411  }
412  return 0;
413 }
414 
415 DIR *opendir(const char *path)
416 {
417  return _ps2sdk_opendir(path);
418 }
419 
420 struct dirent *readdir(DIR *dir)
421 {
422  return _ps2sdk_readdir(dir);
423 }
424 
425 void rewinddir(DIR *dir)
426 {
427  return _ps2sdk_rewinddir(dir);
428 }
429 
430 int closedir(DIR *dir)
431 {
432  return _ps2sdk_closedir(dir);
433 }
434 
435 int _isatty(int fd) {
436  struct stat buf;
437 
438  if (_fstat (fd, &buf) < 0) {
439  //errno = EBADF;
440  return 0;
441  }
442  if (S_ISCHR (buf.st_mode))
443  return 1;
444  //errno = ENOTTY;
445  return 0;
446 }
447 
448 off_t _lseek(int fd, off_t offset, int whence)
449 {
450  return _ps2sdk_lseek(fd, offset, whence);
451 }
452 
453 off64_t lseek64(int fd, off64_t offset, int whence)
454 {
455  if (_ps2sdk_lseek64 == NULL)
456  return EOVERFLOW;
457 
458  return _ps2sdk_lseek64(fd, offset, whence);
459 }
460 
461 int chdir(const char *path) {
462  strcpy(__direct_pwd, path);
463  return 0;
464 }
465 
466 int mkdir(const char *path, mode_t mode) {
467  return _ps2sdk_mkdir(path, mode);
468 }
469 
470 int rmdir(const char *path) {
471  return _ps2sdk_rmdir(path);
472 }
473 
474 int _link(const char *old, const char *new) {
475  return _ps2sdk_rename(old, new);
476 }
477 
478 int _unlink(const char *path) {
479  return _ps2sdk_remove(path);
480 }
481 
482 char *getcwd(char *buf, size_t len) {
483  strncpy(buf, __direct_pwd, len);
484  return buf;
485 }
486 
487 int _getpid(void) {
488  return GetThreadId();
489 }
490 
491 int _kill(int pid, int sig) {
492 #if 0 // needs to be tested first
493  // null signal: do error checking on pid only
494  if (sig == 0)
495  return pid == getpid() ? 0 : -1;
496 
497  if (pid == getpid()) {
499  // NOTE: ExitDeleteThread does not return
500  return 0;
501  }
502 #endif
503  // FIXME: set errno
504  return -1;
505 }
506 
507 void * _sbrk(size_t incr) {
508  return ps2_sbrk(incr);
509 }
510 
511 /*
512  * newlib function, unfortunately depends on the 'cdvd' library.
513  * In libc there is a dummy 'time' function declared as WEAK.
514  * In cdvd there is a working 'time' function declared as STRONG
515  * Include libcdvd if you need to use the time function.
516  */
517 time_t time(time_t *t) __attribute__((weak));
518 time_t time(time_t *t)
519 {
520  printf("ERROR: include libcdvd when using the time function\n");
521 
522  if(t != NULL)
523  *t = -1;
524  return -1;
525 }
526 
527 /*
528  * Implement in terms of time, which means we can't
529  * return the microseconds.
530  */
531 int _gettimeofday(struct timeval *tv, struct timezone *tz) {
532  if (tz) {
533  /* Timezone not supported for gettimeofday */
534  tz->tz_minuteswest = 0;
535  tz->tz_dsttime = 0;
536  }
537 
538  tv->tv_usec = 0;
539  tv->tv_sec = time(0);
540 
541  return 0;
542 }
543 
544 clock_t _times(struct tms *buffer) {
545  clock_t clk = ps2_clock() / (PS2_CLOCKS_PER_SEC / CLOCKS_PER_SEC);
546 
547  if (buffer != NULL) {
548  buffer->tms_utime = clk;
549  buffer->tms_stime = 0;
550  buffer->tms_cutime = clk;
551  buffer->tms_cstime = 0;
552  }
553 
554  return clk;
555 }
556 
557 long int random(void)
558 {
559  return rand();
560 }
561 
562 void srandom(unsigned int seed)
563 {
564  srand(seed);
565 }
#define ENOSYS
Definition: errno.h:180
#define EOVERFLOW
Definition: errno.h:257
int fioRmdir(const char *dirname)
int fioWrite(int fd, const void *buff, int buff_size)
int fioRead(int fd, void *buff, int buff_size)
int fioMkdir(const char *dirname)
int fioGetstat(const char *name, io_stat_t *buf)
int fioRemove(const char *name)
int fioDclose(int fd)
int fioIoctl(int fd, int request, void *data)
int fioDopen(const char *name)
int fioClose(int fd)
int fioDread(int fd, io_dirent_t *buf)
int fioLseek(int fd, int offset, int whence)
int fioOpen(const char *fname, int mode)
#define FIO_SO_IFDIR
Definition: iox_stat.h:126
#define FIO_SO_IXOTH
Definition: iox_stat.h:133
#define FIO_SO_IWOTH
Definition: iox_stat.h:131
#define FIO_SO_IFREG
Definition: iox_stat.h:124
#define FIO_SO_IROTH
Definition: iox_stat.h:129
void ExitDeleteThread(void)
s32 GetThreadId(void)
s32 s
Definition: ps2ipc.c:30
DIR *(* _ps2sdk_opendir)(const char *path)
Definition: ps2sdkapi.c:185
int(* _ps2sdk_stat)(const char *path, struct stat *buf)
Definition: ps2sdkapi.c:183
int chdir(const char *path)
Definition: ps2sdkapi.c:461
#define IOP_O_WRONLY
Definition: ps2sdkapi.c:191
int _kill(int pid, int sig)
Definition: ps2sdkapi.c:491
int _open(const char *buf, int flags,...)
Definition: ps2sdkapi.c:301
int _fstat(int fd, struct stat *buf)
Definition: ps2sdkapi.c:382
void(* _ps2sdk_rewinddir)(DIR *dir)
Definition: ps2sdkapi.c:187
#define IOP_O_CREAT
Definition: ps2sdkapi.c:196
int _unlink(const char *path)
Definition: ps2sdkapi.c:478
static int isCdromPath(const char *path)
Definition: ps2sdkapi.c:296
static void fill_stat(struct stat *stat, const io_stat_t *fiostat)
Definition: ps2sdkapi.c:80
clock_t _times(struct tms *buffer)
Definition: ps2sdkapi.c:544
#define ct_assert(e)
Definition: ps2sdkapi.c:211
int _stat(const char *path, struct stat *buf)
Definition: ps2sdkapi.c:397
int64_t(* _ps2sdk_lseek64)(int, int64_t, int)
Definition: ps2sdkapi.c:175
#define IOP_O_TRUNC
Definition: ps2sdkapi.c:197
long int random(void)
Definition: ps2sdkapi.c:557
#define IOP_O_RDONLY
Definition: ps2sdkapi.c:190
int(* _ps2sdk_closedir)(DIR *dir)
Definition: ps2sdkapi.c:188
int _isatty(int fd)
Definition: ps2sdkapi.c:435
int _link(const char *old, const char *new)
Definition: ps2sdkapi.c:474
int(* _ps2sdk_lseek)(int, int, int)
Definition: ps2sdkapi.c:174
void * _sbrk(size_t incr)
Definition: ps2sdkapi.c:507
int mkdir(const char *path, mode_t mode)
Definition: ps2sdkapi.c:466
#define IOP_O_NBLOCK
Definition: ps2sdkapi.c:194
int _close(int fd)
Definition: ps2sdkapi.c:366
int(* _ps2sdk_write)(int, const void *, int)
Definition: ps2sdkapi.c:176
int fioMkdirHelper(const char *path, int mode)
Definition: ps2sdkapi.c:52
#define IOP_O_EXCL
Definition: ps2sdkapi.c:198
static void fioRewinddirHelper(DIR *dir)
Definition: ps2sdkapi.c:152
int(* _ps2sdk_close)(int)
Definition: ps2sdkapi.c:171
off_t _lseek(int fd, off_t offset, int whence)
Definition: ps2sdkapi.c:448
char __direct_pwd[256]
Definition: ps2sdkapi.c:45
off64_t lseek64(int fd, off64_t offset, int whence)
Definition: ps2sdkapi.c:453
int access(const char *fn, int flags)
Definition: ps2sdkapi.c:401
int _read(int fd, void *buf, size_t nbytes)
Definition: ps2sdkapi.c:370
static int fioGetstatHelper(const char *path, struct stat *buf)
Definition: ps2sdkapi.c:97
int _gettimeofday(struct timeval *tv, struct timezone *tz)
Definition: ps2sdkapi.c:531
#define IOP_O_APPEND
Definition: ps2sdkapi.c:195
int _getpid(void)
Definition: ps2sdkapi.c:487
char * getcwd(char *buf, size_t len)
Definition: ps2sdkapi.c:482
int(* _ps2sdk_ioctl)(int, int, void *)
Definition: ps2sdkapi.c:177
static struct dirent * fioReaddirHelper(DIR *dir)
Definition: ps2sdkapi.c:128
static mode_t io_to_posix_mode(unsigned int ps2mode)
Definition: ps2sdkapi.c:69
int(* _ps2sdk_remove)(const char *)
Definition: ps2sdkapi.c:178
void rewinddir(DIR *dir)
Definition: ps2sdkapi.c:425
int rmdir(const char *path)
Definition: ps2sdkapi.c:470
void * ps2_sbrk(size_t increment)
Definition: sbrk.c:22
int(* _ps2sdk_rename)(const char *, const char *)
Definition: ps2sdkapi.c:179
static char * normalize_path(const char *path_name)
Definition: ps2sdkapi.c:237
int closedir(DIR *dir)
Definition: ps2sdkapi.c:430
static int fioClosedirHelper(DIR *dir)
Definition: ps2sdkapi.c:157
#define IOP_O_RDWR
Definition: ps2sdkapi.c:192
struct dirent * readdir(DIR *dir)
Definition: ps2sdkapi.c:420
int fioRename(const char *old, const char *new)
Definition: ps2sdkapi.c:48
time_t time(time_t *t)
Definition: ps2sdkapi.c:518
static DIR * fioOpendirHelper(const char *path)
Definition: ps2sdkapi.c:110
struct dirent *(* _ps2sdk_readdir)(DIR *dir)
Definition: ps2sdkapi.c:186
int(* _ps2sdk_read)(int, void *, int)
Definition: ps2sdkapi.c:173
static time_t io_to_posix_time(const unsigned char *ps2time)
Definition: ps2sdkapi.c:57
int(* _ps2sdk_mkdir)(const char *, int)
Definition: ps2sdkapi.c:180
void srandom(unsigned int seed)
Definition: ps2sdkapi.c:562
void compile_time_check()
Definition: ps2sdkapi.c:212
int(* _ps2sdk_rmdir)(const char *)
Definition: ps2sdkapi.c:181
int(* _ps2sdk_open)(const char *, int,...)
Definition: ps2sdkapi.c:172
DIR * opendir(const char *path)
Definition: ps2sdkapi.c:415
int _write(int fd, const void *buf, size_t nbytes)
Definition: ps2sdkapi.c:374
#define PS2_CLOCKS_PER_SEC
Definition: ps2sdkapi.h:38
int64_t off64_t
Definition: ps2sdkapi.h:48
ps2_clock_t ps2_clock(void)
s32 mode
Definition: rpc_client.c:15
u8 buffer[128]
Definition: rpc_client.c:19
char name[256]
Definition: io_common.h:59
io_stat_t stat
Definition: io_common.h:58
unsigned char atime[8]
Definition: io_common.h:52
unsigned int size
Definition: io_common.h:50
unsigned int mode
Definition: io_common.h:48
unsigned char ctime[8]
Definition: io_common.h:51
unsigned int hisize
Definition: io_common.h:54
unsigned char mtime[8]
Definition: io_common.h:53
#define NULL
Definition: tamtypes.h:91
unsigned int u32
Definition: tamtypes.h:30
unsigned int u128
Definition: tamtypes.h:36
unsigned short u16
Definition: tamtypes.h:24
unsigned char u8
Definition: tamtypes.h:23
unsigned long u64
Definition: tamtypes.h:34
#define O_NONBLOCK
Definition: tcpip.h:1574