Changeset 1152
- Timestamp:
- 04/24/11 04:01:38 (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
include/stdlib.h (modified) (2 diffs)
-
platform/generic/wrappers.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/stdlib.h
r1151 r1152 203 203 }; 204 204 #else 205 // NOTE this is not complete and may not be accurate for all versions 205 206 struct dirent { 206 207 char d_name[13]; … … 214 215 #endif 215 216 216 // NOTE this is NOT the actual structure returned by dryos opendir! 217 #if !CAM_DRYOS 217 218 typedef struct { 218 unsigned int fd; // first member is an fd from Open in dryos219 unsigned int fd; 219 220 unsigned int loc; 220 221 struct dirent dir; 221 222 } DIR; 222 223 #else 224 // structure returned by dryos 225 // actual size may vary depending on version 226 typedef struct { 227 int fh; 228 int unk[4]; 229 } DIR_dryos; 230 231 // struct returned by our wrappers around opendir 232 typedef struct { 233 DIR_dryos *dh; 234 #ifdef CAM_DRYOS_2_3_R39 235 char de_buf[64]; 236 #else 237 char de_buf[40]; 238 #endif 239 } DIR; 240 #endif 223 241 224 242 extern DIR* opendir (const char* name); -
trunk/platform/generic/wrappers.c
r1151 r1152 362 362 } 363 363 364 //---------------------------------------------------------------------------- 365 // directory wrappers 366 #ifndef CAM_DRYOS 364 367 void *opendir(const char* name) { 365 368 return _opendir(name); 366 369 } 367 368 370 void* readdir(void *d) { 369 # if !CAM_DRYOS370 371 return _readdir(d); 371 #else 372 // TODO this makes a single static buffer for all directory handles. 373 // This means you can only use one at a time, unless you memcpy! 374 #ifdef CAM_DRYOS_2_3_R39 375 static char de[64]; 376 #else 377 static char de[40]; 378 #endif 379 380 _ReadFastDir(d, de); 381 return de[0]? de : (void*)0; 382 #endif 383 } 384 372 } 385 373 int closedir(void *d) { 386 374 return _closedir(d); … … 390 378 return _rewinddir(d); 391 379 } 380 #else // dryos 381 // TODO duplicated in stdlib.h! 382 // structure returned by dryos 383 // actual size may vary depending on version 384 typedef struct { 385 int fh; 386 int unk[4]; 387 } DIR_dryos; 388 389 // struct returned by our wrappers around opendir 390 typedef struct { 391 DIR_dryos *dh; 392 #ifdef CAM_DRYOS_2_3_R39 393 char de_buf[64]; 394 #else 395 char de_buf[40]; 396 #endif 397 } DIR; 398 399 DIR *opendir(const char* name) { 400 DIR *d; 401 DIR_dryos *dh = _opendir(name); 402 if(!dh) { 403 return (void *)0; 404 } 405 d = _malloc(sizeof(DIR)); 406 if(!d) { 407 _closedir(dh); 408 return (void *)0; 409 } 410 d->dh = dh; 411 return d; 412 } 413 414 void* readdir(DIR *d) { 415 _ReadFastDir(d->dh, d->de_buf); 416 return d->de_buf[0]? d->de_buf : (void*)0; 417 } 418 419 int closedir(DIR *d) { 420 int r; 421 if(!d) { 422 return -1; 423 } 424 r = _closedir(d->dh); 425 _free(d); 426 return r; 427 } 428 429 void rewinddir(DIR *d) { 430 if(!d) { 431 return; 432 } 433 _rewinddir(d->dh); 434 } 435 #endif // dryos dir functions 392 436 393 437 int stat(char *name, void *pStat) {
Note: See TracChangeset
for help on using the changeset viewer.