MCPcopy Create free account
hub / github.com/aiekick/ImGuiFileDialog / ScanDirectory

Method ScanDirectory

ImGuiFileDialog.cpp:554–599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552 }
553
554 std::vector<IGFD::FileInfos> ScanDirectory(const std::string& vPath) override {
555 std::vector<IGFD::FileInfos> res;
556 try {
557 namespace fs = std::filesystem;
558 auto fspath = stringToPath(vPath);
559 const auto dir_iter = fs::directory_iterator(fspath);
560 IGFD::FileType fstype = IGFD::FileType(IGFD::FileType::ContentType::Directory, fs::is_symlink(fs::status(fspath)));
561 {
562 IGFD::FileInfos file_two_dot;
563 file_two_dot.filePath = vPath;
564 file_two_dot.fileNameExt = "..";
565 file_two_dot.fileType = fstype;
566 res.push_back(file_two_dot);
567 }
568 for (const auto& file : dir_iter) {
569 try {
570 IGFD::FileType fileType;
571 if (file.is_symlink()) {
572 fileType.SetSymLink(file.is_symlink());
573 fileType.SetContent(IGFD::FileType::ContentType::LinkToUnknown);
574 }
575 if (file.is_directory()) {
576 fileType.SetContent(IGFD::FileType::ContentType::Directory);
577 } // directory or symlink to directory
578 else if (file.is_regular_file()) {
579 fileType.SetContent(IGFD::FileType::ContentType::File);
580 }
581 if (fileType.isValid()) {
582 auto fileNameExt = pathToString(file.path().filename());
583 {
584 IGFD::FileInfos _file;
585 _file.filePath = vPath;
586 _file.fileNameExt = fileNameExt;
587 _file.fileType = fileType;
588 res.push_back(_file);
589 }
590 }
591 } catch (const std::exception& ex) {
592 std::cout << "IGFD : " << ex.what() << std::endl;
593 }
594 }
595 } catch (const std::exception& ex) {
596 std::cout << "IGFD : " << ex.what() << std::endl;
597 }
598 return res;
599 }
600 bool IsDirectory(const std::string& vFilePathName) override {
601 namespace fs = std::filesystem;
602 return fs::is_directory(stringToPath(vFilePathName));

Callers 2

ScanDirMethod · 0.45

Calls 6

stringToPathFunction · 0.85
pathToStringFunction · 0.85
SetSymLinkMethod · 0.80
SetContentMethod · 0.80
isValidMethod · 0.80
whatMethod · 0.80

Tested by

no test coverage detected