commit 5e2e506e
Changed default backend to Xml and default path to ~/oastat. It will now also be autocreated if missing
git-svn-id: http://oastat.googlecode.com/svn/trunk@41 a36be8df-c75f-1e49-46ad-4f0ee64bdc62
Changed files
| M | src/db/Db2Xml.cpp before |
| M | src/oastat.cpp before |
diff --git a/src/db/Db2Xml.cpp b/src/db/Db2Xml.cpp
index df01b03..9e327b7 100644
--- a/src/db/Db2Xml.cpp
+++ b/src/db/Db2Xml.cpp
@@ -10,16 +10,21 @@
Db2Xml::Db2Xml()
{
- p_output_dir = "~/oastat";
- p_postscript = "";
psoudo_playerids.clear();
nextId = 1;
- //mkdir(p_output_dir.c_str());
+ boost::format path("%1%/oastat");
+ path % getenv("HOME");
+ p_output_dir = path.str();
+ boost::format fmkdir("mkdir -p %1%");
+ fmkdir % p_output_dir;
+ system(fmkdir.str().c_str());
}
Db2Xml::Db2Xml(string dbargs)
{
- p_output_dir = "~/oastat";
- p_postscript = "";
+ boost::format path("%1%/oastat");
+ path % getenv("HOME");
+ p_output_dir = path.str();
+ p_postscript = "";
psoudo_playerids.clear();
nextId = 1;
//mkdir(p_output_dir.c_str());
@@ -38,7 +43,10 @@ Db2Xml::Db2Xml(string dbargs)
if(holder == "postscript")
p_postscript = param;
}
- }
+ }
+ boost::format fmkdir("mkdir -p %1%");
+ fmkdir % p_output_dir;
+ system(fmkdir.str().c_str());
}
Db2Xml::Db2Xml(const Db2Xml& orig)
{
@@ -82,6 +90,8 @@ void Db2Xml::endGame(int second)
% (p_gametime.tm_hour) % (p_gametime.tm_min) % (p_gametime.tm_sec) ).str();
ofstream outfile;
outfile.open (filename.c_str());
+ if(outfile.fail())
+ cout << "could not create " << filename << endl;
outfile << p_xmlcontent;
outfile.close();
cout << "End game at " << second << "with size " << p_xmlcontent.length() << " written to " << filename << endl;
diff --git a/src/oastat.cpp b/src/oastat.cpp
index b96c051..93a99e0 100644
--- a/src/oastat.cpp
+++ b/src/oastat.cpp
@@ -104,11 +104,13 @@ int main (int argc, const char* argv[])
{
string dbargs = "";
string filename = "";
- string backend = "DbiXX";
+ string backend = "Xml";
bool useTail = false;
/////////////
- dbargs = "mysql dbname oastat username poul";
- filename = "/home/poul/.openarena/elimination/games.log";
+ //dbargs = "mysql dbname oastat";
+ boost::format f("%1%/.openarena/baseoa/games.log");
+ f % getenv("HOME");
+ filename = f.str();
////////////
for(int i=1;i<argc;i++) {
bool onemore = i+1<argc;
@@ -220,7 +222,7 @@ static int processStdIn(istream* in_p) {
//try {
//cout << "checking " << commands.at(i)->getCommand() << endl;
if(commands.at(i)->canProcess(oss)) {
- //cout << "Exectured by " << commands.at(i)->getCommand();
+ //cout << "Execturedg by " << commands.at(i)->getCommand();
commands.at(i)->process(oss);
}
/*} catch (exception &e)