Skip to content

Instantly share code, notes, and snippets.

@gusugusu1018
Last active January 30, 2021 13:11
Show Gist options
  • Save gusugusu1018/a2e60de1fbd9bab89376b3cbc2fe2f6c to your computer and use it in GitHub Desktop.
Save gusugusu1018/a2e60de1fbd9bab89376b3cbc2fe2f6c to your computer and use it in GitHub Desktop.
#include <cassert>
#include <iostream>
#include <string>
#include <filesystem>
int main(int argc, const char** argv) {
std::string inputPathname;
if (argc == 2) {
inputPathname = argv[1];
} else {
std::cout << "Too few arguments" << std::endl;
return 1;
}
std::filesystem::path inputPath = inputPathname.c_str();
bool res = std::filesystem::exists(inputPath);
if (!res) {
std::cout << "could not open " << inputPathname << std::endl;
return -1;
}
std::cout << "target directory : " << inputPath << std::endl;
for (const auto & entry : std::filesystem::directory_iterator(inputPath)) {
if (entry.path().extension() == ".xml") {
std::cout << entry.path() << std::endl;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment