.gitignore, beginning of cellar.json support

This commit is contained in:
Nicholas O'Connor 2017-03-12 23:10:04 -07:00
parent 107c00f769
commit e30cddee84
2 changed files with 37 additions and 3 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
*.in
*.o
*/.deps
compile
config.*
configure
depcomp
install-sh
missing

View File

@ -1,20 +1,44 @@
#include <cstdlib> #include <cstdlib>
#include <fstream>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <sstream>
#include <vector> #include <vector>
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include "json.hpp"
#include "fs.hpp" #include "fs.hpp"
using namespace std; using namespace std;
using json = nlohmann::json;
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
vector<string> homedir = cellar::fs::listdir(getenv("HOME")); string homepath = getenv("HOME");
vector<string> homedir = cellar::fs::listdir(homepath);
for (string item : homedir) { for (string item : homedir) {
if (item.substr(0,5) == ".wine") {
cout << item; cout << item;
cout << " "; cout << " ";
string jsonpath = homepath + "/" + item + "/cellar.json";
if (boost::filesystem::exists(jsonpath)) {
try {
json config;
ifstream configstream(jsonpath);
stringstream sstr;
sstr << configstream.rdbuf();
config = json::parse(sstr.str());
cout << "has a json" << endl;
}
catch (const exception &exc) {
cout << "- bogus cellar.json file" << endl;
}
}
else { cout << "- anonymous wine bottle" << endl; }
}
} }
cout << endl; cout << endl;
return 0; return 0;