| 2392 | }; |
| 2393 | |
| 2394 | BFP_EXPORT BfpFindFileData* BFP_CALLTYPE BfpFindFileData_FindFirstFile(const char* path, BfpFindFileFlags flags, BfpFileResult* outResult) |
| 2395 | { |
| 2396 | Beefy::String findStr = path; |
| 2397 | Beefy::String wildcard; |
| 2398 | |
| 2399 | int lastSlashPos = std::max((int)findStr.LastIndexOf('/'), (int)findStr.LastIndexOf('\\')); |
| 2400 | if (lastSlashPos != -1) |
| 2401 | { |
| 2402 | wildcard = findStr.Substring(lastSlashPos + 1); |
| 2403 | findStr = findStr.Substring(0, lastSlashPos); |
| 2404 | } |
| 2405 | if (wildcard == "*.*") |
| 2406 | wildcard = "*"; |
| 2407 | |
| 2408 | DIR* dir = opendir(findStr.c_str()); |
| 2409 | if (dir == NULL) |
| 2410 | { |
| 2411 | OUTRESULT(BfpFileResult_NotFound); |
| 2412 | return NULL; |
| 2413 | } |
| 2414 | |
| 2415 | BfpFindFileData* findData = new BfpFindFileData(); |
| 2416 | findData->mFlags = flags; |
| 2417 | findData->mDirPath = findStr; |
| 2418 | findData->mDirStruct = dir; |
| 2419 | findData->mWildcard = wildcard; |
| 2420 | findData->mHasStat = false; |
| 2421 | findData->mDirEnt = NULL; |
| 2422 | |
| 2423 | if (!BfpFindFileData_FindNextFile(findData)) |
| 2424 | { |
| 2425 | OUTRESULT(BfpFileResult_NoResults); |
| 2426 | closedir(findData->mDirStruct); |
| 2427 | delete findData; |
| 2428 | return NULL; |
| 2429 | } |
| 2430 | |
| 2431 | OUTRESULT(BfpFileResult_Ok); |
| 2432 | return findData; |
| 2433 | } |
| 2434 | |
| 2435 | static void GetStat(BfpFindFileData* findData) |
| 2436 | { |
nothing calls this directly
no test coverage detected