summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/ServerI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceGrid/ServerI.cpp')
-rw-r--r--cpp/src/IceGrid/ServerI.cpp23
1 files changed, 13 insertions, 10 deletions
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 <IceUtil/FileUtil.h>
#include <Ice/Ice.h>
+#include <Ice/Instance.h>
#include <IceGrid/ServerI.h>
#include <IceGrid/TraceLevels.h>
#include <IceGrid/Activator.h>
@@ -20,7 +22,6 @@
#include <IceUtil/FileUtil.h>
#include <sys/types.h>
-#include <sys/stat.h>
#ifdef _WIN32
# include <direct.h>
@@ -33,8 +34,6 @@
# include <dirent.h>
#endif
-#include <fstream>
-
using namespace std;
using namespace IceGrid;
@@ -275,6 +274,7 @@ private:
struct EnvironmentEval : std::unary_function<string, string>
{
+
string
operator()(const std::string& value)
{
@@ -289,7 +289,8 @@ struct EnvironmentEval : std::unary_function<string, string>
string::size_type beg = 0;
string::size_type end;
#ifdef _WIN32
- char buf[32767];
+ vector<wchar_t> 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<string, string>
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<string, string>
#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;