** Implementation of the POSIX readdir() function using the MSVCRT. */
| 1424 | ** Implementation of the POSIX readdir() function using the MSVCRT. |
| 1425 | */ |
| 1426 | LPDIRENT readdir( |
| 1427 | LPDIR dirp |
| 1428 | ){ |
| 1429 | struct _finddata_t data; |
| 1430 | |
| 1431 | if( dirp==NULL ) return NULL; |
| 1432 | |
| 1433 | if( dirp->d_first.d_ino==0 ){ |
| 1434 | dirp->d_first.d_ino++; |
| 1435 | dirp->d_next.d_ino++; |
| 1436 | |
| 1437 | return &dirp->d_first; |
| 1438 | } |
| 1439 | |
| 1440 | next: |
| 1441 | |
| 1442 | memset(&data, 0, sizeof(struct _finddata_t)); |
| 1443 | if( _findnext(dirp->d_handle, &data)==-1 ) return NULL; |
| 1444 | |
| 1445 | /* TODO: Remove this block to allow hidden and/or system files. */ |
| 1446 | if( is_filtered(data) ) goto next; |
| 1447 | |
| 1448 | dirp->d_next.d_ino++; |
| 1449 | dirp->d_next.d_attributes = data.attrib; |
| 1450 | strncpy(dirp->d_next.d_name, data.name, NAME_MAX); |
| 1451 | dirp->d_next.d_name[NAME_MAX] = '\0'; |
| 1452 | |
| 1453 | return &dirp->d_next; |
| 1454 | } |
| 1455 | |
| 1456 | /* |
| 1457 | ** Implementation of the POSIX readdir_r() function using the MSVCRT. |
no outgoing calls
no test coverage detected