Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<std::string> get_all_files_names_within_folder(std::string folder) {
- std::vector<std::string> names;
- std::string search_path = folder + "/*.*";
- std::string fullFilename;
- WIN32_FIND_DATA fd;
- HANDLE hFind = ::FindFirstFile(search_path.c_str(), &fd);
- if (hFind != INVALID_HANDLE_VALUE) {
- int index = 0;
- do {
- if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- fullFilename = fd.cFileName;
- // we not save jpg files
- if (fullFilename.substr(fullFilename.find_last_of(".") + 1).find("jpg") == std::string::npos) {
- std::string fullname = folder;
- fullname.append(fd.cFileName);
- names.push_back(fullname);
- }
- }
- } while (::FindNextFile(hFind, &fd));
- ::FindClose(hFind);
- const size_t last_slash_idx = folder.find_last_of("\\/");
- if (std::string::npos != last_slash_idx)
- {
- folder.erase(0, last_slash_idx + 1);
- }
- return names;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement