Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <experimental/filesystem>
- #include <string>
- namespace fs = std::experimental::filesystem;
- int main() {
- std::string path = "/tmp";
- std::string ext = ".jpg";
- for (const auto & entry : fs::directory_iterator(path)) {
- std::string curExt = entry.path().extension().c_str();
- if (std::equal(ext.begin(), ext.end(), curExt.begin())) {
- std::cout << entry.path() << std::endl;
- }
- }
- }
- // clang++ ls.cpp -std=c++11 -lstdc++fs
Advertisement
Add Comment
Please, Sign In to add comment