MCPcopy Create free account
hub / github.com/Tencent/MMKV / walkInDir

Function walkInDir

Core/MemoryFile_Win32.cpp:592–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590}
591
592void walkInDir(const MMKVPath_t &dirPath,
593 WalkType type,
594 const std::function<void(const MMKVPath_t &, WalkType)> &walker) {
595 wchar_t szDir[MAX_PATH];
596 StringCchCopy(szDir, MAX_PATH, dirPath.c_str());
597 StringCchCat(szDir, MAX_PATH, L"\\*");
598
599 WIN32_FIND_DATA ffd;
600 auto hFind = FindFirstFile(szDir, &ffd);
601 if (hFind == INVALID_HANDLE_VALUE) {
602 return;
603 }
604
605 do {
606 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
607 if (type & WalkFolder) {
608 if (wcscmp(ffd.cFileName, L".") == 0 || wcscmp(ffd.cFileName, L"..") == 0) {
609 continue;
610 }
611 walker(dirPath + L"\\" + ffd.cFileName, WalkFolder);
612 }
613 } else if (type & WalkFile) {
614 walker(dirPath + L"\\" + ffd.cFileName, WalkFile);
615 }
616 } while (FindNextFile(hFind, &ffd) != 0);
617
618 auto dwError = GetLastError();
619 if (dwError != ERROR_NO_MORE_FILES) {
620 MMKVError("WalkInDir fail %d", dwError);
621 }
622
623 FindClose(hFind);
624}
625
626bool isDiskOfMMAPFileCorrupted(MemoryFile *file, bool &needReportReadFail) {
627 // make sure the file is valid

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected