Skip to content

Commit

Permalink
Get config file in windows is OK
Browse files Browse the repository at this point in the history
  • Loading branch information
vintagewang committed Jun 9, 2012
1 parent 8ecdcd8 commit 20d5102
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
8 changes: 8 additions & 0 deletions src/JWUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ namespace JWUtil
char bufFileName[512 + 1] = {0};
GetModuleFileNameA(NULL, bufFileName, sizeof(bufFileName) - 1);
result = bufFileName;

//
// remove file extention
//
std::string::size_type pos = result.find_last_of('.');
if(pos != std::string::npos) {
result = result.substr(0, pos);
}
#else
#endif

Expand Down
4 changes: 3 additions & 1 deletion src/JavaConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ JavaConfig* JavaConfig::getInstance()
bool JavaConfig::load()
{
ptree pt;
read_xml("jwrapper.xml", pt);
read_xml(getConfigFile().c_str(), pt);
this->javaHome = pt.get<string>("java.javahome");
this->mainClass = pt.get<string>("java.mainclass");

Expand All @@ -46,6 +46,8 @@ void JavaConfig::printAll()
for(size_t i = 0; i < this->classPathList.size(); i++) {
printf("CLASS PATH %2d = [%s]\n", i, this->classPathList[i].c_str());
}

printf("EXE = [%s]\n", this->getConfigFile().c_str());
}

std::string JavaConfig::getConfigFile()
Expand Down
16 changes: 0 additions & 16 deletions src/jwrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
#include "JavaConfig.h"

//void test_ptree()
//{
// ptree pt;
// read_xml("jwrapper.xml", pt);
// cout << pt.get<string>("java.javahome") << endl;
// cout << pt.get<string>("java.mainclass") << endl;
//
// BOOST_AUTO(child, pt.get_child("java.classpaths"));
// for(BOOST_AUTO(pos, child.begin());
// pos != child.end();
// ++pos)
// {
// cout << pos->second.data() << ",";
// }
//}

int main(int argc, char** argv)
{
bool result = JavaConfig::getInstance()->load();
Expand Down

0 comments on commit 20d5102

Please sign in to comment.