MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / getFilesAndDirsWithFindImpl

Function getFilesAndDirsWithFindImpl

src/envfs.cpp:411–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409{}
410
411void getFilesAndDirsWithFindImpl(const std::wstring& path, Directory& d)
412{
413 const std::wstring searchString = path + L"\\*";
414
415 WIN32_FIND_DATAW findData;
416
417 HANDLE searchHandle =
418 ::FindFirstFileExW(searchString.c_str(), FindExInfoBasic, &findData,
419 FindExSearchNameMatch, nullptr, FIND_FIRST_EX_LARGE_FETCH);
420
421 if (searchHandle != INVALID_HANDLE_VALUE) {
422 BOOL result = true;
423
424 while (result) {
425 if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
426 if ((wcscmp(findData.cFileName, L".") != 0) &&
427 (wcscmp(findData.cFileName, L"..") != 0)) {
428 const std::wstring newPath = path + L"\\" + findData.cFileName;
429 d.dirs.push_back(Directory(findData.cFileName));
430 getFilesAndDirsWithFindImpl(newPath, d.dirs.back());
431 }
432 } else {
433 const auto size =
434 (findData.nFileSizeHigh * (MAXDWORD + 1)) + findData.nFileSizeLow;
435
436 d.files.push_back(File(findData.cFileName, findData.ftLastWriteTime, size));
437 }
438
439 result = ::FindNextFileW(searchHandle, &findData);
440 }
441 }
442
443 ::FindClose(searchHandle);
444}
445
446Directory getFilesAndDirsWithFind(const std::wstring& path)
447{

Callers 1

getFilesAndDirsWithFindFunction · 0.85

Calls 3

backMethod · 0.80
DirectoryClass · 0.70
FileClass · 0.70

Tested by

no test coverage detected