MCPcopy Create free account
hub / github.com/beefytech/Beef / BfpFindFileData_FindFirstFile

Function BfpFindFileData_FindFirstFile

BeefySysLib/platform/posix/PosixCommon.cpp:2394–2433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2392};
2393
2394BFP_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
2435static void GetStat(BfpFindFileData* findData)
2436{

Callers

nothing calls this directly

Calls 4

SubstringMethod · 0.80
LastIndexOfMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected