| 590 | } |
| 591 | |
| 592 | void 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 | |
| 626 | bool isDiskOfMMAPFileCorrupted(MemoryFile *file, bool &needReportReadFail) { |
| 627 | // make sure the file is valid |
nothing calls this directly
no outgoing calls
no test coverage detected