diff options
Diffstat (limited to 'cpp/src/IceUtil')
-rw-r--r-- | cpp/src/IceUtil/FileUtil.cpp | 135 | ||||
-rw-r--r-- | cpp/src/IceUtil/InputUtil.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IceUtil/OutputUtil.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceUtil/Random.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IceUtil/Thread.cpp | 4 |
5 files changed, 9 insertions, 150 deletions
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index b69e8d6b20a..58e321c5d63 100644 --- a/cpp/src/IceUtil/FileUtil.cpp +++ b/cpp/src/IceUtil/FileUtil.cpp @@ -170,7 +170,7 @@ IceUtilInternal::unlink(const string& path) int IceUtilInternal::close(int fd) { -#if defined(_MSC_VER) && (_MSC_VER >= 1400) || defined(__MINGW32__) +#ifdef __MINGW32__ return _close(fd); #else return ::close(fd); @@ -228,95 +228,10 @@ IceUtilInternal::FileLock::~FileLock() unlink(_path); } -#ifdef _STLP_BEGIN_NAMESPACE -namespace -{ -int -toFileFlags(ios_base::openmode mode) -{ - int flags = 0; - if(mode & ios_base::app) - { - flags |= _O_APPEND; - } - if(mode & ios_base::trunc) - { - flags |= _O_TRUNC; - } - if(mode & ios_base::binary) - { - flags |= _O_BINARY; - } - if((mode & ios_base::in) && !(mode & ios_base::out)) - { - flags |= _O_RDONLY; - } - else if((mode & ios_base::out) && !(mode & ios_base::in)) - { - flags |= _O_WRONLY | _O_CREAT; - } - else - { - flags |= _O_RDWR; - if(mode & ios_base::trunc) - { - flags |= _O_CREAT; - } - } - return flags; -} -} -#endif - IceUtilInternal::ifstream::ifstream() -#ifdef _STLP_BEGIN_NAMESPACE - : _fd(-1) -#endif -{ -} - -#ifdef _STLP_BEGIN_NAMESPACE - -IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode) : _fd(-1) { - open(path, mode); } -IceUtilInternal::ifstream::~ifstream() -{ - close(); -} - -void -IceUtilInternal::ifstream::close() -{ - if(!rdbuf()->close()) - { - setstate(ios_base::failbit); - } - if(_fd >= 0) - { - _close(_fd); - } -} - -void -IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode) -{ - mode |= ifstream::in; - _fd = IceUtilInternal::open(path, toFileFlags(mode)); - if(_fd < 0 || !rdbuf()->open(_fd, mode)) - { - setstate(ios_base::failbit); - } - if(mode & (ios_base::ate || ios_base::app)) - { - seekg(ios_base::end); - } -} - -#else - IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode) : #ifdef __MINGW32__ std::ifstream(path.c_str(), mode) @@ -336,57 +251,10 @@ IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode) #endif } -#endif - IceUtilInternal::ofstream::ofstream() -#ifdef _STLP_BEGIN_NAMESPACE - : _fd(-1) -#endif -{ -} - -#ifdef _STLP_BEGIN_NAMESPACE - -IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode) : _fd(-1) -{ - open(path, mode); -} - -IceUtilInternal::ofstream::~ofstream() -{ - close(); -} - -void -IceUtilInternal::ofstream::close() { - if(!rdbuf()->close()) - { - setstate(ios_base::failbit); - } - if(_fd >= 0) - { - _close(_fd); - } } -void -IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode) -{ - mode |= ofstream::out; - _fd = IceUtilInternal::open(path, toFileFlags(mode)); - if(_fd < 0 || !rdbuf()->open(_fd, mode)) - { - setstate(ios_base::failbit); - } - if(mode & (ios_base::ate || ios_base::app)) - { - seekp(ios_base::end); - } -} - -#else - IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode) : #ifdef __MINGW32__ std::ofstream(path.c_str(), mode) @@ -406,7 +274,6 @@ IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode) #endif } -#endif #else diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp index 8f5edab81f9..058331a0552 100644 --- a/cpp/src/IceUtil/InputUtil.cpp +++ b/cpp/src/IceUtil/InputUtil.cpp @@ -11,7 +11,7 @@ #include <stdlib.h> #include <errno.h> -#if (defined(_MSC_VER) && (_MSC_VER < 1300) ) || (__MINGW32__) +#ifdef __MINGW32__ #include <limits.h> #endif @@ -26,10 +26,10 @@ namespace IceUtilInternal { -#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1300)) +#ifdef __MINGW32__ // -// The VC60 runtime does not include _strtoi64, so we provide our own implementation +// The MINGW runtime does not include _strtoi64, so we provide our own implementation // static const string allDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -179,7 +179,7 @@ Int64 strToInt64(const char* s, char** endptr, int base) { #if defined(_WIN32) -# if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1300)) +# ifdef __MINGW32__ return strToInt64Impl(s, endptr, base); # else return _strtoi64(s, endptr, base); diff --git a/cpp/src/IceUtil/OutputUtil.cpp b/cpp/src/IceUtil/OutputUtil.cpp index 989eb5bba9c..00464533d98 100644 --- a/cpp/src/IceUtil/OutputUtil.cpp +++ b/cpp/src/IceUtil/OutputUtil.cpp @@ -35,11 +35,7 @@ IceUtilInternal::int64ToString(Int64 val) { char buf[64]; #ifdef _WIN32 -#if defined(_MSC_VER) && (_MSC_VER >= 1400) sprintf_s(buf, sizeof(buf), "%I64d", val); -#else - sprintf(buf, "%I64d", val); -#endif #elif defined(ICE_64) sprintf(buf, "%ld", val); // Avoids a format warning from GCC. #else diff --git a/cpp/src/IceUtil/Random.cpp b/cpp/src/IceUtil/Random.cpp index d47d424357f..f5bb19ba43b 100644 --- a/cpp/src/IceUtil/Random.cpp +++ b/cpp/src/IceUtil/Random.cpp @@ -7,7 +7,7 @@ // // ********************************************************************** -#if defined(_MSC_VER) && (_MSC_VER > 1400) +#ifdef _MSC_VER # define _CRT_RAND_S #endif @@ -25,7 +25,7 @@ using namespace std; using namespace IceUtil; -#if !defined(_WIN32) || !defined(_MSC_VER) || (_MSC_VER < 1400) +#if !defined(_WIN32) || !defined(_MSC_VER) namespace { @@ -88,7 +88,7 @@ IceUtilInternal::generateRandom(char* buffer, int size) { #ifdef _WIN32 -# if defined(_MSC_VER) && (_MSC_VER >= 1400) +# if defined(_MSC_VER) for(int i = 0; i < size; ++i) { buffer[i] = random(256); @@ -168,7 +168,7 @@ unsigned int IceUtilInternal::random(int limit) { unsigned int r; -#if defined(_MSC_VER) && (_MSC_VER > 1400) +#if defined(_MSC_VER) errno_t err = rand_s(&r); if(err != 0) { diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index 4c63bd7b0e2..fef17c9629d 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -181,11 +181,7 @@ WINAPI startHook(void* arg) { cerr << thread->name() << " terminating" << endl; } -#if defined(_MSC_VER) && (_MSC_VER < 1300) - terminate(); -#else std::terminate(); -#endif } thread->_done(); |