.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 <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include "json.hpp"
#include "fs.hpp"
using namespace std;
using json = nlohmann::json;
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) {
cout << item;
cout << " ";
if (item.substr(0,5) == ".wine") {
cout << item;
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;
return 0;