Commit 10af7420 by xiaojing.zhang

reset client.xml

parent 6c2ee258
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "global.h" #include "global.h"
#include "QsLog.h" #include "QsLog.h"
#include <QFile>
#define XML_FREEMUD_CLIENT "Client.xml" #define XML_FREEMUD_CLIENT "Client.xml"
//extern char XML_FREEMUD_CLIENT[256]; //extern char XML_FREEMUD_CLIENT[256];
...@@ -1356,7 +1358,8 @@ public: ...@@ -1356,7 +1358,8 @@ public:
static bool JsonConvertFront(const Document &srcdoc, Document &desdoc, string &key, string &values, string &lasterror) static bool JsonConvertFront(const Document &srcdoc, Document &desdoc, string &key, string &values, string &lasterror)
{ {
xml_document<> doc; xml_document<> doc;
string posxml; //string posxml;
string currPath;
stringstream error; stringstream error;
if (srcdoc.HasParseError() || desdoc.HasParseError() || srcdoc.IsNull()) if (srcdoc.HasParseError() || desdoc.HasParseError() || srcdoc.IsNull())
...@@ -1369,19 +1372,24 @@ public: ...@@ -1369,19 +1372,24 @@ public:
if(desdoc.IsNull()) if(desdoc.IsNull())
desdoc.Parse<0>("{}"); desdoc.Parse<0>("{}");
GetProcPath(posxml); GetProcPath(currPath);
string realPath = currPath;
QString filename = Tool::ReadCfg(CFG_SECTION_XMLFILENAME, XML_FREEMUD_CLIENT).toString(); QString filename = Tool::ReadCfg(CFG_SECTION_XMLFILENAME, XML_FREEMUD_CLIENT).toString();
posxml.append(filename.toStdString()); realPath.append(filename.toStdString());
if(!QFile::exists(QString::fromStdString(realPath))) {
realPath = currPath + XML_FREEMUD_CLIENT;
}
QLOG_DEBUG() << "JsonConvertFront xml name :" << QString::fromStdString(posxml); QLOG_DEBUG() << "JsonConvertFront xml name :" << QString::fromStdString(realPath);
#ifdef WIN32 #ifdef WIN32
if(_access(posxml.data(), 0) == -1) if(_access(realPath.data(), 0) == -1)
#else #else
if(access(posxml.data(), F_OK) == -1) if(access(realPath.data(), F_OK) == -1)
#endif #endif
{ {
error << posxml << " not found"; error << realPath << " not found";
lasterror = error.str(); lasterror = error.str();
return false; return false;
} }
...@@ -1389,7 +1397,7 @@ public: ...@@ -1389,7 +1397,7 @@ public:
try try
{ {
file<> fdoc(posxml.c_str()); file<> fdoc(realPath.c_str());
if(GetXMLDocumentHandle(fdoc, doc, error) == false) if(GetXMLDocumentHandle(fdoc, doc, error) == false)
...@@ -1417,7 +1425,8 @@ public: ...@@ -1417,7 +1425,8 @@ public:
static bool JsonConvertPost(const Document &srcdoc, Document &desdoc, string key, string values, string &lasterror) static bool JsonConvertPost(const Document &srcdoc, Document &desdoc, string key, string values, string &lasterror)
{ {
xml_document<> doc; xml_document<> doc;
string posxml; //string posxml;
string currPath;
stringstream error; stringstream error;
if(key.empty() || values.empty()) if(key.empty() || values.empty())
...@@ -1434,25 +1443,31 @@ public: ...@@ -1434,25 +1443,31 @@ public:
return false; return false;
} }
GetProcPath(posxml); GetProcPath(currPath);
string realPath = currPath;
QString filename = Tool::ReadCfg(CFG_SECTION_XMLFILENAME, XML_FREEMUD_CLIENT).toString(); QString filename = Tool::ReadCfg(CFG_SECTION_XMLFILENAME, XML_FREEMUD_CLIENT).toString();
posxml.append(filename.toStdString()); realPath.append(filename.toStdString());
QLOG_DEBUG() << "JsonConvertPost xml name :" << QString::fromStdString(posxml);
if(!QFile::exists(QString::fromStdString(realPath))) {
realPath = currPath + XML_FREEMUD_CLIENT;
}
QLOG_DEBUG() << "JsonConvertPost xml name :" << QString::fromStdString(realPath);
#ifdef WIN32 #ifdef WIN32
if(_access(posxml.data(), 0) == -1) if(_access(realPath.data(), 0) == -1)
#else #else
if(access(posxml.data(), F_OK) == -1) if(access(realPath.data(), F_OK) == -1)
#endif #endif
{ {
error << posxml << " not found"; error << realPath << " not found";
lasterror = error.str(); lasterror = error.str();
return false; return false;
} }
try try
{ {
file<> fdoc(posxml.c_str()); file<> fdoc(realPath.c_str());
if(GetXMLDocumentHandle(fdoc, doc, error) == false) if(GetXMLDocumentHandle(fdoc, doc, error) == false)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment