summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2016-07-08 10:50:18 -0400
committerBernard Normier <bernard@zeroc.com>2016-07-08 10:50:18 -0400
commit3e6c7c189ba3d623845dfc385f143cc49e4be8aa (patch)
tree5e0dfa828891d67c230736a6cf4f5adeb2216097
parentAdditional UWP fix for ICE-7172 (diff)
downloadice-3e6c7c189ba3d623845dfc385f143cc49e4be8aa.tar.bz2
ice-3e6c7c189ba3d623845dfc385f143cc49e4be8aa.tar.xz
ice-3e6c7c189ba3d623845dfc385f143cc49e4be8aa.zip
Removed IceUtilInternal ifstream and ofstream
-rw-r--r--cpp/include/IceUtil/FileUtil.h60
-rw-r--r--cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp4
-rw-r--r--cpp/src/Ice/Instance.cpp1
-rw-r--r--cpp/src/Ice/LoggerI.cpp5
-rw-r--r--cpp/src/Ice/LoggerI.h4
-rw-r--r--cpp/src/Ice/PropertiesI.cpp3
-rw-r--r--cpp/src/Ice/Service.cpp2
-rw-r--r--cpp/src/IceGrid/FileCache.cpp5
-rw-r--r--cpp/src/IceGrid/FileUserAccountMapperI.cpp3
-rw-r--r--cpp/src/IceGrid/PlatformInfo.cpp3
-rw-r--r--cpp/src/IceGrid/ServerI.cpp9
-rwxr-xr-xcpp/src/IceSSL/Util.cpp7
-rw-r--r--cpp/src/IceStorm/IceStormDB.cpp8
-rw-r--r--cpp/src/IceUtil/FileUtil.cpp91
-rw-r--r--cpp/src/IceXML/Parser.cpp3
-rw-r--r--cpp/src/icegriddb/IceGridDB.cpp9
-rw-r--r--php/src/php7/Communicator.cpp3
17 files changed, 60 insertions, 160 deletions
diff --git a/cpp/include/IceUtil/FileUtil.h b/cpp/include/IceUtil/FileUtil.h
index c42d3265225..aa70fd28b32 100644
--- a/cpp/include/IceUtil/FileUtil.h
+++ b/cpp/include/IceUtil/FileUtil.h
@@ -17,7 +17,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
-#include <fstream>
namespace IceUtilInternal
{
@@ -114,14 +113,14 @@ public:
// file.
//
FileLock(const std::string&);
-
+
//
// The destructor releases the lock and removes the file.
//
virtual ~FileLock();
-
+
private:
-
+
#ifdef _WIN32
HANDLE _fd;
#else
@@ -132,51 +131,18 @@ private:
typedef IceUtil::Handle<FileLock> FileLockPtr;
-class ICE_API ifstream : public std::ifstream
-{
-public:
-
- ifstream();
- ifstream(const std::string&, std::ios_base::openmode mode = std::ios_base::in);
- void open(const std::string&, std::ios_base::openmode mode = std::ios_base::in);
-
-#ifdef __SUNPRO_CC
- using std::ifstream::open;
-#endif
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1900)
- ifstream(const ifstream&) = delete;
-#endif
-
-private:
-
- // Hide const char* definitions since they shouldn't be used.
- ifstream(const char*);
- void open(const char*, std::ios_base::openmode mode = std::ios_base::in);
-};
-
-class ICE_API ofstream : public std::ofstream
+//
+// Use streamFilename to construct the filename given to std stream classes
+// like ifstream and ofstream.
+//
+#if defined(_WIN32) && !defined(__MINGW32__)
+ICE_API const wchar_t* streamFilename(const std::string&);
+#else
+inline const char* streamFilename(const std::string& filename)
{
-public:
-
- ofstream();
- ofstream(const std::string&, std::ios_base::openmode mode = std::ios_base::out);
- void open(const std::string&, std::ios_base::openmode mode = std::ios_base::out);
-
-#ifdef __SUNPRO_CC
- using std::ofstream::open;
+ return filename.c_str();
+}
#endif
-#if defined(_MSC_VER) && (_MSC_VER >= 1900)
- ofstream(const ofstream&) = delete;
-#endif
-
-private:
-
- // Hide const char* definitions since they shouldn't be used.
- ofstream(const char*);
- void open(const char*, std::ios_base::openmode mode = std::ios_base::out);
-};
-
}
#endif
diff --git a/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp b/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp
index e3387c4667d..df705e99022 100644
--- a/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp
+++ b/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp
@@ -16,6 +16,8 @@
#include <IceUtil/InputUtil.h>
#include <IceUtil/Mutex.h>
+#include <fstream>
+
#if defined(__GLIBC__) || defined(_AIX)
# include <crypt.h>
#elif defined(__FreeBSD__)
@@ -96,7 +98,7 @@ private:
map<string, string>
retrievePasswordMap(const string& file)
{
- IceUtilInternal::ifstream passwordFile(file);
+ ifstream passwordFile(IceUtilInternal::streamFilename(file));
if(!passwordFile)
{
string err = IceUtilInternal::lastErrorToString();
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index bb3260b9139..ae4a2a07a61 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -45,6 +45,7 @@
#include <Ice/Functional.h>
#include <IceUtil/DisableWarnings.h>
+#include <IceUtil/FileUtil.h>
#include <IceUtil/StringUtil.h>
#include <IceUtil/UUID.h>
#include <IceUtil/Mutex.h>
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp
index ced361d0588..09e58b762d7 100644
--- a/cpp/src/Ice/LoggerI.cpp
+++ b/cpp/src/Ice/LoggerI.cpp
@@ -14,6 +14,7 @@
#include <IceUtil/MutexPtrLock.h>
#include <Ice/LocalException.h>
+#include <IceUtil/FileUtil.h>
using namespace std;
using namespace Ice;
@@ -69,7 +70,7 @@ Ice::LoggerI::LoggerI(const string& prefix, const string& file,
if(!file.empty())
{
_file = file;
- _out.open(file, fstream::out | fstream::app);
+ _out.open(IceUtilInternal::streamFilename(file), fstream::out | fstream::app);
if(!_out.is_open())
{
throw InitializationException(__FILE__, __LINE__, "FileLogger: cannot open " + _file);
@@ -198,7 +199,7 @@ Ice::LoggerI::write(const string& message, bool indent)
int err = IceUtilInternal::rename(_file, archive);
- _out.open(_file, fstream::out | fstream::app);
+ _out.open(IceUtilInternal::streamFilename(_file), fstream::out | fstream::app);
if(err)
{
diff --git a/cpp/src/Ice/LoggerI.h b/cpp/src/Ice/LoggerI.h
index c48e768d1b4..580371a9f83 100644
--- a/cpp/src/Ice/LoggerI.h
+++ b/cpp/src/Ice/LoggerI.h
@@ -11,8 +11,8 @@
#define ICE_LOGGER_I_H
#include <Ice/Logger.h>
-#include <IceUtil/FileUtil.h>
#include <IceUtil/StringConverter.h>
+#include <fstream>
namespace Ice
{
@@ -40,7 +40,7 @@ private:
std::string _formattedPrefix;
const bool _convert;
const IceUtil::StringConverterPtr _converter;
- IceUtilInternal::ofstream _out;
+ std::ofstream _out;
std::string _file;
std::size_t _sizeMax;
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp
index 1f03133ddf3..6570d16e9da 100644
--- a/cpp/src/Ice/PropertiesI.cpp
+++ b/cpp/src/Ice/PropertiesI.cpp
@@ -16,6 +16,7 @@
#include <Ice/Logger.h>
#include <Ice/LoggerUtil.h>
#include <Ice/Communicator.h>
+#include <fstream>
using namespace std;
using namespace Ice;
@@ -398,7 +399,7 @@ Ice::PropertiesI::load(const std::string& file)
else
#endif
{
- IceUtilInternal::ifstream in(file);
+ ifstream in(IceUtilInternal::streamFilename(file));
if(!in)
{
FileException ex(__FILE__, __LINE__);
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp
index d4a11deacef..b739818e2cd 100644
--- a/cpp/src/Ice/Service.cpp
+++ b/cpp/src/Ice/Service.cpp
@@ -1776,7 +1776,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
//
if(_pidFile.size() > 0)
{
- IceUtilInternal::ofstream of(_pidFile);
+ ofstream of(_pidFile.c_str());
of << getpid() << endl;
if(!of)
diff --git a/cpp/src/IceGrid/FileCache.cpp b/cpp/src/IceGrid/FileCache.cpp
index eb877b6dd68..79848729aa0 100644
--- a/cpp/src/IceGrid/FileCache.cpp
+++ b/cpp/src/IceGrid/FileCache.cpp
@@ -16,6 +16,7 @@
#include <IceGrid/Exception.h>
#include <deque>
+#include <fstream>
using namespace std;
using namespace IceGrid;
@@ -28,7 +29,7 @@ FileCache::FileCache(const Ice::CommunicatorPtr& com) :
Ice::Long
FileCache::getOffsetFromEnd(const string& file, int originalCount)
{
- IceUtilInternal::ifstream is(file); // file is a UTF-8 string
+ ifstream is(IceUtilInternal::streamFilename(file)); // file is a UTF-8 string
if(is.fail())
{
throw FileNotAvailableException("failed to open file `" + file + "'");
@@ -140,7 +141,7 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
throw FileNotAvailableException("maximum bytes per read request is too low");
}
- IceUtilInternal::ifstream is(file); // file is a UTF-8 string
+ ifstream is(IceUtilInternal::streamFilename(file)); // file is a UTF-8 string
if(is.fail())
{
throw FileNotAvailableException("failed to open file `" + file + "'");
diff --git a/cpp/src/IceGrid/FileUserAccountMapperI.cpp b/cpp/src/IceGrid/FileUserAccountMapperI.cpp
index 3b44a3e9050..545dbaeb6af 100644
--- a/cpp/src/IceGrid/FileUserAccountMapperI.cpp
+++ b/cpp/src/IceGrid/FileUserAccountMapperI.cpp
@@ -10,13 +10,14 @@
#include <IceUtil/DisableWarnings.h>
#include <IceUtil/FileUtil.h>
#include <IceGrid/FileUserAccountMapperI.h>
+#include <fstream>
using namespace std;
using namespace IceGrid;
FileUserAccountMapperI::FileUserAccountMapperI(const string& filename)
{
- IceUtilInternal::ifstream file(filename); // filename is a UTF-8 string
+ ifstream file(IceUtilInternal::streamFilename(filename)); // filename is a UTF-8 string
if(!file)
{
throw "cannot open `" + filename + "' for reading: " + strerror(errno);
diff --git a/cpp/src/IceGrid/PlatformInfo.cpp b/cpp/src/IceGrid/PlatformInfo.cpp
index 320181cfaa3..92f98729301 100644
--- a/cpp/src/IceGrid/PlatformInfo.cpp
+++ b/cpp/src/IceGrid/PlatformInfo.cpp
@@ -19,6 +19,7 @@
#include <set>
#include <climits>
+#include <fstream>
#if defined(_WIN32)
# include <pdhmsg.h> // For PDH_MORE_DATA
@@ -300,7 +301,7 @@ PlatformInfo::PlatformInfo(const string& prefix,
#if defined(_WIN32)
_nProcessorSockets = getSocketCount(_traceLevels->logger);
#elif defined(__linux)
- IceUtilInternal::ifstream is(string("/proc/cpuinfo"));
+ ifstream is("/proc/cpuinfo");
set<string> ids;
int nprocessor = 0;
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 404b1e77606..ef33e07a8be 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -22,6 +22,7 @@
#include <IceUtil/FileUtil.h>
#include <sys/types.h>
+#include <fstream>
#ifdef _WIN32
# include <direct.h>
@@ -2311,7 +2312,7 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
knownFiles.push_back(p->first);
const string configFilePath = _serverDir + "/config/" + p->first;
- IceUtilInternal::ofstream configfile(configFilePath); // configFilePath is a UTF-8 string
+ ofstream configfile(IceUtilInternal::streamFilename(configFilePath)); // configFilePath is a UTF-8 string
if(!configfile.good())
{
throw "couldn't create configuration file: " + configFilePath;
@@ -2413,7 +2414,7 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
{
string file = dbEnvHome + "/DB_CONFIG";
- IceUtilInternal::ofstream configfile(file); // file is a UTF-8 string
+ ofstream configfile(IceUtilInternal::streamFilename(file)); // file is a UTF-8 string
if(!configfile.good())
{
throw "couldn't create configuration file `" + file + "'";
@@ -2485,7 +2486,7 @@ ServerI::checkRevision(const string& replicaName, const string& uuid, int revisi
else
{
string idFilePath = _serverDir + "/revision";
- IceUtilInternal::ifstream is(idFilePath); // idFilePath is a UTF-8 string
+ ifstream is(IceUtilInternal::streamFilename(idFilePath)); // idFilePath is a UTF-8 string
if(!is.good())
{
return;
@@ -2674,7 +2675,7 @@ ServerI::updateRevision(const string& uuid, int revision)
}
string idFilePath = _serverDir + "/revision";
- IceUtilInternal::ofstream os(idFilePath); // idFilePath is a UTF-8 string
+ ofstream os(IceUtilInternal::streamFilename(idFilePath)); // idFilePath is a UTF-8 string
if(os.good())
{
os << "#" << endl;
diff --git a/cpp/src/IceSSL/Util.cpp b/cpp/src/IceSSL/Util.cpp
index ced265c943e..2bd931be770 100755
--- a/cpp/src/IceSSL/Util.cpp
+++ b/cpp/src/IceSSL/Util.cpp
@@ -20,6 +20,7 @@
#include <Ice/LocalException.h>
#include <Ice/Network.h>
#include <Ice/Object.h>
+#include <fstream>
#ifdef ICE_USE_OPENSSL
# include <openssl/err.h>
@@ -206,7 +207,7 @@ unsigned char dh4096_g[] = { 0x02 };
//
// With OpenSSL 1.1.0 is no longer possible to acess the DH p and g
// data members to set the DH params. We still use the same default
-// parameters but they were converted to DER format using
+// parameters but they were converted to DER format using
// i2d_DHparams and can be restored using d2i_DHparams
unsigned char dh512[] =
@@ -611,7 +612,7 @@ namespace
CFDataRef
readCertFile(const string& file)
{
- IceUtilInternal::ifstream is(file, ios::in | ios::binary);
+ ifstream is(IceUtilInternal::streamFilename(file), ios::in | ios::binary);
if(!is.good())
{
throw CertificateReadException(__FILE__, __LINE__, "error opening file " + file);
@@ -1654,7 +1655,7 @@ IceSSL::findCertificates(const string& location, const string& name, const strin
void
IceSSL::readFile(const string& file, vector<char>& buffer)
{
- IceUtilInternal::ifstream is(file, ios::in | ios::binary);
+ ifstream is(IceUtilInternal::streamFilename(file), ios::in | ios::binary);
if(!is.good())
{
throw CertificateReadException(__FILE__, __LINE__, "error opening file " + file);
diff --git a/cpp/src/IceStorm/IceStormDB.cpp b/cpp/src/IceStorm/IceStormDB.cpp
index 20ff33ed6a6..dc8357893ce 100644
--- a/cpp/src/IceStorm/IceStormDB.cpp
+++ b/cpp/src/IceStorm/IceStormDB.cpp
@@ -8,10 +8,12 @@
// **********************************************************************
#include <IceUtil/Options.h>
-#include <Ice/Application.h>
+#include <IceUtil/FileUtil.h>
+#include <Ice/Ice.h>
#include <IceDB/IceDB.h>
#include <IceStorm/DBTypes.h>
#include <IceUtil/DisableWarnings.h>
+#include <fstream>
using namespace std;
using namespace Ice;
@@ -157,7 +159,7 @@ Client::run(int argc, char* argv[])
return EXIT_FAILURE;
}
- ifstream fs(dbFile.c_str(), ios::binary);
+ ifstream fs(IceUtilInternal::streamFilename(dbFile), ios::binary);
if(fs.fail())
{
cerr << argv[0] << ": could not open input file: " << strerror(errno) << endl;
@@ -300,7 +302,7 @@ Client::run(int argc, char* argv[])
stream.write(ICE_INT_VERSION);
stream.write(data);
- ofstream fs(dbFile.c_str(), ios::binary);
+ ofstream fs(IceUtilInternal::streamFilename(dbFile), ios::binary);
if(fs.fail())
{
cerr << argv[0] << ": could not open output file: " << strerror(errno) << endl;
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp
index 4e3dc407804..13cedac2d2a 100644
--- a/cpp/src/IceUtil/FileUtil.cpp
+++ b/cpp/src/IceUtil/FileUtil.cpp
@@ -344,68 +344,13 @@ IceUtilInternal::FileLock::~FileLock()
unlink(_path);
}
-IceUtilInternal::ifstream::ifstream()
+#ifndef __MINGW32__
+const wchar_t*
+IceUtilInternal::streamFilename(const string& filename)
{
+ return IceUtil::stringToWstring(filename, IceUtil::getProcessStringConverter()).c_str();
}
-
-IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode) :
-#ifdef __MINGW32__
- std::ifstream(path.c_str(), mode)
-#else
- //
- // Don't need to use a wide string converter, the wide string is directly passed
- // to Windows API.
- //
- std::ifstream(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode)
-#endif
-{
-}
-
-void
-IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode)
-{
-#ifdef __MINGW32__
- std::ifstream::open(path.c_str(), mode);
-#else
- //
- // Don't need to use a wide string converter, the wide string is directly passed
- // to Windows API.
- //
- std::ifstream::open(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode);
#endif
-}
-
-IceUtilInternal::ofstream::ofstream()
-{
-}
-
-IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode) :
-#ifdef __MINGW32__
- std::ofstream(path.c_str(), mode)
-#else
- //
- // Don't need to use a wide string converter, the wide string is directly passed
- // to Windows API.
- //
- std::ofstream(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode)
-#endif
-{
-}
-
-void
-IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode)
-{
-#ifdef __MINGW32__
- std::ofstream::open(path.c_str(), mode);
-#else
- //
- // Don't need to use a wide string converter, the wide string is directly passed
- // to Windows API.
- //
- std::ofstream::open(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode);
-#endif
-}
-
#else
@@ -541,32 +486,4 @@ IceUtilInternal::FileLock::~FileLock()
unlink(_path);
}
-IceUtilInternal::ifstream::ifstream()
-{
-}
-
-IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode) : std::ifstream(path.c_str(), mode)
-{
-}
-
-void
-IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode)
-{
- std::ifstream::open(path.c_str(), mode);
-}
-
-IceUtilInternal::ofstream::ofstream()
-{
-}
-
-IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode) : std::ofstream(path.c_str(), mode)
-{
-}
-
-void
-IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode)
-{
- std::ofstream::open(path.c_str(), mode);
-}
-
#endif
diff --git a/cpp/src/IceXML/Parser.cpp b/cpp/src/IceXML/Parser.cpp
index 5cae7178956..4f753ef933e 100644
--- a/cpp/src/IceXML/Parser.cpp
+++ b/cpp/src/IceXML/Parser.cpp
@@ -11,6 +11,7 @@
#include <IceUtil/FileUtil.h>
#include <expat.h>
#include <list>
+#include <fstream>
using namespace std;
using namespace IceXML;
@@ -401,7 +402,7 @@ IceXML::Parser::parse(istream& in)
void
IceXML::Parser::parse(const string& file, Handler& handler) // The given filename must be UTF-8 encoded
{
- IceUtilInternal::ifstream in(file);
+ ifstream in(IceUtilInternal::streamFilename(file));
if(!in.good())
{
ostringstream out;
diff --git a/cpp/src/icegriddb/IceGridDB.cpp b/cpp/src/icegriddb/IceGridDB.cpp
index 55fc370fa8f..71e9e7b6028 100644
--- a/cpp/src/icegriddb/IceGridDB.cpp
+++ b/cpp/src/icegriddb/IceGridDB.cpp
@@ -8,12 +8,15 @@
// **********************************************************************
#include <IceUtil/Options.h>
-#include <Ice/Application.h>
+#include <IceUtil/FileUtil.h>
+#include <Ice/Ice.h>
#include <IceDB/IceDB.h>
#include <IceGrid/Admin.h>
#include <IceGrid/DBTypes.h>
#include <IceUtil/DisableWarnings.h>
+#include <fstream>
+
using namespace std;
using namespace Ice;
using namespace IceGrid;
@@ -264,7 +267,7 @@ Client::run(int argc, char* argv[])
return EXIT_FAILURE;
}
- ifstream fs(dbFile.c_str(), ios::binary);
+ ifstream fs(IceUtilInternal::streamFilename(dbFile), ios::binary);
if(fs.fail())
{
cerr << argv[0] << ": could not open input file: " << strerror(errno) << endl;
@@ -536,7 +539,7 @@ Client::run(int argc, char* argv[])
stream.write(ICE_INT_VERSION);
stream.write(data);
- ofstream fs(dbFile.c_str(), ios::binary);
+ ofstream fs(IceUtilInternal::streamFilename(dbFile), ios::binary);
if(fs.fail())
{
cerr << argv[0] << ": could not open output file: " << strerror(errno) << endl;
diff --git a/php/src/php7/Communicator.cpp b/php/src/php7/Communicator.cpp
index e9c00aa4c28..e6c34e4b5ac 100644
--- a/php/src/php7/Communicator.cpp
+++ b/php/src/php7/Communicator.cpp
@@ -18,6 +18,7 @@
#include <IceUtil/MutexPtrLock.h>
#include <IceUtil/StringUtil.h>
#include <IceUtil/Timer.h>
+#include <fstream>
#ifdef getcwd
#undef getcwd
@@ -1531,7 +1532,7 @@ parseProfiles(const string& file)
// ice.config = config-file
// ice.options = args
//
- IceUtilInternal::ifstream in(file);
+ ifstream in(IceUtilInternal::streamFilename(file));
if(!in)
{
php_error_docref(0, E_WARNING, "unable to open Ice profiles in %s", file.c_str());