MCPcopy Create free account
hub / github.com/PDAL/PDAL / glob

Function glob

pdal/util/FileUtils.cpp:465–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463
464
465std::vector<std::string> glob(std::string path)
466{
467 // replace with VSIGlob in GDAL 3.11
468 std::vector<std::string> filenames;
469
470 if (path[0] == '~')
471 throw pdal::pdal_error("PDAL does not support shell expansion");
472
473#ifdef _WIN32
474#ifdef PDAL_WIN32_STL
475 std::wstring wpath(toNative(path));
476 WIN32_FIND_DATAW ffd;
477 HANDLE handle = FindFirstFileW(wpath.c_str(), &ffd);
478
479 if (INVALID_HANDLE_VALUE == handle)
480 return filenames;
481
482 size_t found = wpath.find_last_of(L"/\\");
483 do
484 {
485 // Ignore files starting with '.' to be consistent with UNIX.
486 if (ffd.cFileName[0] == L'.')
487 continue;
488 if (found == std::wstring::npos)
489 filenames.push_back(fromNative(ffd.cFileName));
490 else
491 filenames.push_back(fromNative(wpath.substr(0, found + 1)) +
492 fromNative(ffd.cFileName));
493
494 } while (FindNextFileW(handle, &ffd) != 0);
495 FindClose(handle);
496#else
497 WIN32_FIND_DATA ffd;
498 HANDLE handle = FindFirstFileA(path.c_str(), &ffd);
499
500 if (INVALID_HANDLE_VALUE == handle)
501 return filenames;
502
503 size_t found = path.find_last_of("/\\");
504 do
505 {
506 // Ignore files starting with '.' to be consistent with UNIX.
507 if (ffd.cFileName[0] == '.')
508 continue;
509 if (found == std::wstring::npos)
510 filenames.push_back(ffd.cFileName);
511 else
512 filenames.push_back(path.substr(0, found + 1) + ffd.cFileName);
513
514 } while (FindNextFileA(handle, &ffd) != 0);
515 FindClose(handle);
516#endif
517#else
518 glob_t glob_result;
519
520 ::glob(path.c_str(), GLOB_NOSORT, NULL, &glob_result);
521 for (unsigned int i = 0; i < glob_result.gl_pathc; ++i)
522 {

Callers

nothing calls this directly

Calls 2

fromNativeFunction · 0.85
toNativeFunction · 0.70

Tested by

no test coverage detected