** Implementation of the POSIX readdir() function using the MSVCRT. */
| 1210 | ** Implementation of the POSIX readdir() function using the MSVCRT. |
| 1211 | */ |
| 1212 | LPDIRENT readdir( |
| 1213 | LPDIR dirp |
| 1214 | ){ |
| 1215 | struct _finddata_t data; |
| 1216 | |
| 1217 | if( dirp==NULL ) return NULL; |
| 1218 | |
| 1219 | if( dirp->d_first.d_ino==0 ){ |
| 1220 | dirp->d_first.d_ino++; |
| 1221 | dirp->d_next.d_ino++; |
| 1222 | |
| 1223 | return &dirp->d_first; |
| 1224 | } |
| 1225 | |
| 1226 | next: |
| 1227 | |
| 1228 | memset(&data, 0, sizeof(struct _finddata_t)); |
| 1229 | if( _findnext(dirp->d_handle, &data)==-1 ) return NULL; |
| 1230 | |
| 1231 | /* TODO: Remove this block to allow hidden and/or system files. */ |
| 1232 | if( is_filtered(data) ) goto next; |
| 1233 | |
| 1234 | dirp->d_next.d_ino++; |
| 1235 | dirp->d_next.d_attributes = data.attrib; |
| 1236 | strncpy(dirp->d_next.d_name, data.name, NAME_MAX); |
| 1237 | dirp->d_next.d_name[NAME_MAX] = '\0'; |
| 1238 | |
| 1239 | return &dirp->d_next; |
| 1240 | } |
| 1241 | |
| 1242 | /* |
| 1243 | ** Implementation of the POSIX readdir_r() function using the MSVCRT. |
no outgoing calls