From 4247c9e2c2612394a5f4d63a65ba538f975906d4 Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 10 Nov 2009 05:30:26 +0100 Subject: Fixed 3962 - Berkeley DB, problems with unicode paths. --- cpp/src/IceGrid/ServerI.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'cpp/src/IceGrid/ServerI.cpp') diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 3ab2938f7db..a42ed7c5ac8 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -7,7 +7,9 @@ // // ********************************************************************** +#include #include +#include #include #include #include @@ -20,7 +22,6 @@ #include #include -#include #ifdef _WIN32 # include @@ -33,8 +34,6 @@ # include #endif -#include - using namespace std; using namespace IceGrid; @@ -275,6 +274,7 @@ private: struct EnvironmentEval : std::unary_function { + string operator()(const std::string& value) { @@ -289,7 +289,8 @@ struct EnvironmentEval : std::unary_function string::size_type beg = 0; string::size_type end; #ifdef _WIN32 - char buf[32767]; + vector buf; + buf.resize(32767); while((beg = v.find("%", beg)) != string::npos && beg < v.size() - 1) { end = v.find("%", beg + 1); @@ -298,8 +299,8 @@ struct EnvironmentEval : std::unary_function break; } string variable = v.substr(beg + 1, end - beg - 1); - DWORD ret = GetEnvironmentVariable(variable.c_str(), buf, sizeof(buf)); - string valstr = (ret > 0 && ret < sizeof(buf)) ? string(buf) : string(""); + DWORD ret = GetEnvironmentVariableW(IceUtil::stringToWstring(variable).c_str(), &buf[0], buf.size()); + string valstr = (ret > 0 && ret < sizeof(buf.size())) ? IceUtil::wstringToString(&buf[0]) : string(""); v.replace(beg, end - beg + 1, valstr); beg += valstr.size(); } @@ -335,6 +336,7 @@ struct EnvironmentEval : std::unary_function #endif return value.substr(0, assignment) + "=" + v; } + }; } @@ -2201,7 +2203,7 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor) knownFiles.push_back(p->first); const string configFilePath = _serverDir + "/config/" + p->first; - ofstream configfile(configFilePath.c_str()); + IceUtilInternal::ofstream configfile(configFilePath); // configFilePath is a UTF-8 string if(!configfile.good()) { throw "couldn't create configuration file: " + configFilePath; @@ -2261,7 +2263,8 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor) if(!(*q)->properties.empty()) { string file = dbEnvHome + "/DB_CONFIG"; - ofstream configfile(file.c_str()); + + IceUtilInternal::ofstream configfile(file); // file is a UTF-8 string if(!configfile.good()) { throw "couldn't create configuration file `" + file + "'"; @@ -2328,7 +2331,7 @@ ServerI::checkRevision(const string& replicaName, const string& uuid, int revisi else { string idFilePath = _serverDir + "/revision"; - ifstream is(idFilePath.c_str()); + IceUtilInternal::ifstream is(idFilePath); // idFilePath is a UTF-8 string if(!is.good()) { return; @@ -2366,7 +2369,7 @@ ServerI::updateRevision(const string& uuid, int revision) _desc->revision = revision; string idFilePath = _serverDir + "/revision"; - ofstream os(idFilePath.c_str()); + IceUtilInternal::ofstream os(idFilePath); // idFilePath is a UTF-8 string if(os.good()) { os << "#" << endl; -- cgit v1.2.3