Changeset 1152 for trunk/platform/generic/wrappers.c
- Timestamp:
- 04/24/11 04:01:38 (2 years ago)
- File:
-
- 1 edited
-
trunk/platform/generic/wrappers.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.