Created
February 28, 2013 03:31
-
-
Save SeanCline/5053959 to your computer and use it in GitHub Desktop.
Playing with VS2012's preliminary implementation of <filesystem> before work on tr2 was halted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <filesystem> | |
#include <vector> | |
#include <algorithm> | |
#include <exception> | |
using namespace std; | |
using namespace std::tr2::sys; | |
int main() | |
{ | |
auto root = path("c:/"); | |
vector<directory_entry> dir_list; | |
// Just to be sure ... | |
if (!is_directory(root)) { | |
cerr << "Directory \"" << root << "\" not found." << endl; | |
throw runtime_error("Damn."); | |
} | |
// Populate our vector with all child directories. | |
copy_if(directory_iterator(root), directory_iterator(), back_inserter(dir_list), [](directory_entry child) { | |
return is_directory(child.status()); | |
}); | |
// Print our list of subdirectories. | |
for (auto dir : dir_list) | |
{ | |
cout << dir.path() << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment