| 1300 | } |
| 1301 | |
| 1302 | int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, int type, void *user) |
| 1303 | { |
| 1304 | #if defined(CONF_FAMILY_WINDOWS) |
| 1305 | WIN32_FIND_DATA finddata; |
| 1306 | HANDLE handle; |
| 1307 | char buffer[1024*2]; |
| 1308 | int length; |
| 1309 | str_format(buffer, sizeof(buffer), "%s/*", dir); |
| 1310 | |
| 1311 | handle = FindFirstFileA(buffer, &finddata); |
| 1312 | |
| 1313 | if (handle == INVALID_HANDLE_VALUE) |
| 1314 | return 0; |
| 1315 | |
| 1316 | str_format(buffer, sizeof(buffer), "%s/", dir); |
| 1317 | length = str_length(buffer); |
| 1318 | |
| 1319 | /* add all the entries */ |
| 1320 | do |
| 1321 | { |
| 1322 | str_copy(buffer+length, finddata.cFileName, (int)sizeof(buffer)-length); |
| 1323 | if(cb(finddata.cFileName, fs_is_dir(buffer), type, user)) |
| 1324 | break; |
| 1325 | } |
| 1326 | while (FindNextFileA(handle, &finddata)); |
| 1327 | |
| 1328 | FindClose(handle); |
| 1329 | return 0; |
| 1330 | #else |
| 1331 | struct dirent *entry; |
| 1332 | char buffer[1024*2]; |
| 1333 | int length; |
| 1334 | DIR *d = opendir(dir); |
| 1335 | |
| 1336 | if(!d) |
| 1337 | return 0; |
| 1338 | |
| 1339 | str_format(buffer, sizeof(buffer), "%s/", dir); |
| 1340 | length = str_length(buffer); |
| 1341 | |
| 1342 | while((entry = readdir(d)) != NULL) |
| 1343 | { |
| 1344 | str_copy(buffer+length, entry->d_name, (int)sizeof(buffer)-length); |
| 1345 | if(cb(entry->d_name, fs_is_dir(buffer), type, user)) |
| 1346 | break; |
| 1347 | } |
| 1348 | |
| 1349 | /* close the directory and return */ |
| 1350 | closedir(d); |
| 1351 | return 0; |
| 1352 | #endif |
| 1353 | } |
| 1354 | |
| 1355 | int fs_storage_path(const char *appname, char *path, int max) |
| 1356 | { |
nothing calls this directly
no test coverage detected