2017-03-12 22:32:46 -07:00
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include <boost/filesystem/operations.hpp>
|
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
|
|
|
|
|
|
#include "fs.hpp"
|
2017-03-23 18:51:11 -07:00
|
|
|
|
#include "output.hpp"
|
2017-03-12 22:32:46 -07:00
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
vector<string> cellar::fs::listdir(string path) {
|
|
|
|
|
vector<string> result;
|
|
|
|
|
boost::filesystem::path cwd(path);
|
|
|
|
|
boost::filesystem::directory_iterator iter_end;
|
|
|
|
|
|
|
|
|
|
for (boost::filesystem::directory_iterator iter_cwd(cwd); iter_cwd != iter_end; ++iter_cwd) {
|
|
|
|
|
try {
|
|
|
|
|
string item = iter_cwd->path().filename().native();
|
|
|
|
|
|
|
|
|
|
result.push_back(item);
|
|
|
|
|
}
|
|
|
|
|
catch (const exception& exc) {
|
2017-03-23 18:51:11 -07:00
|
|
|
|
// TODO: better error handling
|
|
|
|
|
cellar::output::error("[1;31mfuck[0m");
|
2017-03-12 22:32:46 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|