Enum Functions
unknown
c_cpp
a year ago
2.2 kB
4
Indexable
Never
bool isWhiteListedFolder(const std::string& str) { for (const auto& excludedFolder : whiteListFolders) { if (str.find(excludedFolder) != std::string::npos) { return true; } } return false; } bool isIgnoredExtension(std::string extension) { for (auto& ignored : whiteExts) { if (ignored == extension) { return true; } } return false; } std::vector<std::string> FileIO::EFiles(const std::string& dir_path) { WIN32_FIND_DATAA file_data; HANDLE hfind; std::vector<std::string> files; std::string path = dir_path + "\\*"; hfind = FindFirstFileA(path.c_str(), &file_data); if (hfind != INVALID_HANDLE_VALUE) { do { std::string full_path = dir_path + "\\" + file_data.cFileName; if (file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (strcmp(file_data.cFileName, ".") != 0 && strcmp(file_data.cFileName, "..") != 0) { if (isWhiteListedFolder(full_path) != false) { std::cout << "[i] Skipped Folder: " << full_path << std::endl; } else { std::vector<std::string> sub_files = EFiles(full_path); files.insert( files.end(), sub_files.begin(), sub_files.end() ); } } } else { std::string extension = full_path.substr(full_path.find_last_of(".")); if (!isIgnoredExtension(extension) { files.push_back(full_path); } else { std::cout << "[i] Skipped File: " << file_data.cFileName << std::endl;; } } } while (FindNextFileA(hfind, &file_data)); FindClose(hfind); } return files; }