summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/FileUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceUtil/FileUtil.cpp')
-rw-r--r--cpp/src/IceUtil/FileUtil.cpp139
1 files changed, 24 insertions, 115 deletions
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp
index 62d6869a91f..b006013ca97 100644
--- a/cpp/src/IceUtil/FileUtil.cpp
+++ b/cpp/src/IceUtil/FileUtil.cpp
@@ -17,7 +17,7 @@
#ifdef _WIN32
# include <process.h>
# include <io.h>
-# ifndef ICE_OS_WINRT
+# ifndef ICE_OS_UWP
# include <Shlwapi.h>
# endif
#else
@@ -96,12 +96,12 @@ IceUtilInternal::directoryExists(const string& path)
//
// Determine if a directory exists and is empty.
//
-#ifndef ICE_OS_WINRT
+#ifndef ICE_OS_UWP
bool
IceUtilInternal::isEmptyDirectory(const string& path)
{
# ifdef _WIN32
- return PathIsDirectoryEmptyW(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
+ return PathIsDirectoryEmptyW(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
# else
struct dirent* d;
DIR* dir = opendir(path.c_str());
@@ -154,8 +154,8 @@ IceUtilInternal::freopen(const std::string& path, const std::string& mode, FILE*
// to Windows API.
//
const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter();
- return _wfreopen(IceUtil::stringToWstring(path, converter).c_str(),
- IceUtil::stringToWstring(mode, converter).c_str(), stream);
+ return _wfreopen(stringToWstring(path, converter).c_str(),
+ stringToWstring(mode, converter).c_str(), stream);
# else
return freopen(path.c_str(), mode.c_str(), stream);
# endif
@@ -174,13 +174,13 @@ IceUtilInternal::stat(const string& path, structstat* buffer)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- return _wstat(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), buffer);
+ return _wstat(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), buffer);
}
int
IceUtilInternal::remove(const string& path)
{
- return ::_wremove(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
+ return ::_wremove(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
}
int
@@ -191,8 +191,8 @@ IceUtilInternal::rename(const string& from, const string& to)
// to Windows API.
//
const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter();
- return ::_wrename(IceUtil::stringToWstring(from, converter).c_str(),
- IceUtil::stringToWstring(to, converter).c_str());
+ return ::_wrename(stringToWstring(from, converter).c_str(),
+ stringToWstring(to, converter).c_str());
}
int
@@ -202,7 +202,7 @@ IceUtilInternal::rmdir(const string& path)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- return ::_wrmdir(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
+ return ::_wrmdir(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
}
int
@@ -212,7 +212,7 @@ IceUtilInternal::mkdir(const string& path, int)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- return ::_wmkdir(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
+ return ::_wmkdir(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
}
FILE*
@@ -223,8 +223,8 @@ IceUtilInternal::fopen(const string& path, const string& mode)
// to Windows API.
//
const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter();
- return ::_wfopen(IceUtil::stringToWstring(path, converter).c_str(),
- IceUtil::stringToWstring(mode, converter).c_str());
+ return ::_wfopen(stringToWstring(path, converter).c_str(),
+ stringToWstring(mode, converter).c_str());
}
int
@@ -236,16 +236,16 @@ IceUtilInternal::open(const string& path, int flags)
//
if(flags & _O_CREAT)
{
- return ::_wopen(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(),
+ return ::_wopen(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(),
flags, _S_IREAD | _S_IWRITE);
}
else
{
- return ::_wopen(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), flags);
+ return ::_wopen(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), flags);
}
}
-#ifndef ICE_OS_WINRT
+#ifndef ICE_OS_UWP
int
IceUtilInternal::getcwd(string& cwd)
{
@@ -254,11 +254,11 @@ IceUtilInternal::getcwd(string& cwd)
// from Windows API.
//
wchar_t cwdbuf[_MAX_PATH];
- if(_wgetcwd(cwdbuf, _MAX_PATH) == NULL)
+ if(_wgetcwd(cwdbuf, _MAX_PATH) == ICE_NULLPTR)
{
return -1;
}
- cwd = IceUtil::wstringToString(cwdbuf, IceUtil::getProcessStringConverter());
+ cwd = wstringToString(cwdbuf, IceUtil::getProcessStringConverter());
return 0;
}
#endif
@@ -270,7 +270,7 @@ IceUtilInternal::unlink(const string& path)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- return _wunlink(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
+ return _wunlink(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
}
int
@@ -291,13 +291,13 @@ IceUtilInternal::FileLock::FileLock(const std::string& path) :
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
-#ifndef ICE_OS_WINRT
- _fd = ::CreateFileW(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(),
- GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+#ifndef ICE_OS_UWP
+ _fd = ::CreateFileW(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(),
+ GENERIC_WRITE, 0, ICE_NULLPTR, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, ICE_NULLPTR);
#else
CREATEFILE2_EXTENDED_PARAMETERS params;
params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
- _fd = ::CreateFile2(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(),
+ _fd = ::CreateFile2(stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(),
GENERIC_WRITE, 0, OPEN_ALWAYS, &params);
#endif
_path = path;
@@ -352,69 +352,6 @@ IceUtilInternal::streamFilename(const string& filename)
}
#endif
-IceUtilInternal::ifstream::ifstream()
-{
-}
-
-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
//
@@ -474,7 +411,7 @@ int
IceUtilInternal::getcwd(string& cwd)
{
char cwdbuf[PATH_MAX];
- if(::getcwd(cwdbuf, PATH_MAX) == NULL)
+ if(::getcwd(cwdbuf, PATH_MAX) == ICE_NULLPTR)
{
return -1;
}
@@ -549,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