Guest User

Untitled

a guest
Nov 11th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <experimental/filesystem>
  3. #include <string>
  4.  
  5. namespace fs = std::experimental::filesystem;
  6.  
  7. int main() {
  8.     std::string path = "/tmp";
  9.     std::string ext = ".jpg";
  10.  
  11.     for (const auto & entry : fs::directory_iterator(path)) {
  12.         std::string curExt = entry.path().extension().c_str();
  13.         if (std::equal(ext.begin(), ext.end(), curExt.begin())) {
  14.             std::cout << entry.path() << std::endl;
  15.         }
  16.     }
  17. }
  18.  
  19. // clang++ ls.cpp -std=c++11 -lstdc++fs
Advertisement
Add Comment
Please, Sign In to add comment