diff options
author | Jose <jose@zeroc.com> | 2009-02-19 20:44:56 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2009-02-19 20:44:56 +0100 |
commit | f27cee4065b4282b2028ff97180eca12c67d870b (patch) | |
tree | 5d2b208d0423512877abd26f99bd7f903a762b9d | |
parent | Bug 3410 - remove deprecation of Ice.MonitorConnections (diff) | |
download | ice-f27cee4065b4282b2028ff97180eca12c67d870b.tar.bz2 ice-f27cee4065b4282b2028ff97180eca12c67d870b.tar.xz ice-f27cee4065b4282b2028ff97180eca12c67d870b.zip |
Bug 3650 - Stop using POSIX functions under Windows
-rw-r--r-- | cpp/src/IceGrid/Activator.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IcePatch2/FileServerI.cpp | 28 | ||||
-rw-r--r-- | cpp/src/IcePatch2/Util.cpp | 29 |
3 files changed, 58 insertions, 3 deletions
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index aad9b15b64f..3c5cf1b5dcd 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -482,7 +482,11 @@ Activator::activate(const string& name, // // Make a copy of the command line. // +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + char* cmdbuf = _strdup(cmd.c_str()); +#else char* cmdbuf = strdup(cmd.c_str()); +#endif // // Create the environment block for the child process. We start with the environment diff --git a/cpp/src/IcePatch2/FileServerI.cpp b/cpp/src/IcePatch2/FileServerI.cpp index 46c22513ded..3e14b22e048 100644 --- a/cpp/src/IcePatch2/FileServerI.cpp +++ b/cpp/src/IcePatch2/FileServerI.cpp @@ -101,9 +101,19 @@ IcePatch2::FileServerI::getFileCompressed_async(const AMD_FileServer_getFileComp return; } - if(lseek(fd, static_cast<off_t>(pos), SEEK_SET) != static_cast<off_t>(pos)) + if( +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _lseek(fd, static_cast<off_t>(pos), SEEK_SET) +#else + lseek(fd, static_cast<off_t>(pos), SEEK_SET) +#endif + != static_cast<off_t>(pos)) { +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _close(fd); +#else close(fd); +#endif ostringstream posStr; posStr << pos; @@ -117,13 +127,23 @@ IcePatch2::FileServerI::getFileCompressed_async(const AMD_FileServer_getFileComp IceUtilInternal::ScopedArray<Byte> bytes(new Byte[num]); #ifdef _WIN32 int r; - if((r = read(fd, bytes.get(), static_cast<unsigned int>(num))) == -1) + if((r = +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _read(fd, bytes.get(), static_cast<unsigned int>(num)) +#else + read(fd, bytes.get(), static_cast<unsigned int>(num)) +#endif + ) == -1) #else ssize_t r; if((r = read(fd, bytes.get(), static_cast<size_t>(num))) == -1) #endif { +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _close(fd); +#else close(fd); +#endif FileAccessException ex; ex.reason = "cannot read `" + path + "': " + strerror(errno); @@ -131,7 +151,11 @@ IcePatch2::FileServerI::getFileCompressed_async(const AMD_FileServer_getFileComp return; } +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _close(fd); +#else close(fd); +#endif ret.first = bytes.get(); ret.second = ret.first + r; diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp index ad06e7ebda5..07b5a355919 100644 --- a/cpp/src/IcePatch2/Util.cpp +++ b/cpp/src/IcePatch2/Util.cpp @@ -1085,7 +1085,11 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G stdioFile = OS::fopen(simplify(pathBZ2Temp), "wb"); if(!stdioFile) { +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _close(fd); +#else close(fd); +#endif throw "cannot open `" + pathBZ2Temp + "' for writing:\n" + IceUtilInternal::lastErrorToString(); } @@ -1098,7 +1102,11 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G ex += string(": ") + IceUtilInternal::lastErrorToString(); } fclose(stdioFile); +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _close(fd); +#else close(fd); +#endif throw ex; } } @@ -1108,7 +1116,13 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G while(bytesLeft > 0) { ByteSeq bytes(min(bytesLeft, 1024u*1024)); - if(read(fd, &bytes[0], static_cast<unsigned int>(bytes.size())) == -1) + if( +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _read(fd, &bytes[0], static_cast<unsigned int>(bytes.size())) +#else + read(fd, &bytes[0], static_cast<unsigned int>(bytes.size())) +#endif + == -1) { #ifndef __BCPLUSPLUS__ if(doCompress) @@ -1116,7 +1130,12 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G fclose(stdioFile); } #endif + +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _close(fd); +#else close(fd); +#endif throw "cannot read from `" + path + "':\n" + IceUtilInternal::lastErrorToString(); } bytesLeft -= static_cast<unsigned int>(bytes.size()); @@ -1134,7 +1153,11 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G } BZ2_bzWriteClose(&bzError, bzFile, 0, 0, 0); fclose(stdioFile); +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _close(fd); +#else close(fd); +#endif throw ex; } } @@ -1143,7 +1166,11 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G SHA1_Update(&ctx, reinterpret_cast<const void*>(&bytes[0]), bytes.size()); } +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + _close(fd); +#else close(fd); +#endif #ifndef __BCPLUSPLUS__ if(doCompress) |