diff options
author | Jose <jose@zeroc.com> | 2009-11-27 00:20:42 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2009-11-27 00:20:42 +0100 |
commit | 7cdc3633275e1106de5aa17ee3ce4a0678227c15 (patch) | |
tree | 84358f440f4bec59988238490d7a3ac7226175cc /cpp/src | |
parent | 4279 - alllTest.py fails to run if source path contains white spaces. (diff) | |
download | ice-7cdc3633275e1106de5aa17ee3ce4a0678227c15.tar.bz2 ice-7cdc3633275e1106de5aa17ee3ce4a0678227c15.tar.xz ice-7cdc3633275e1106de5aa17ee3ce4a0678227c15.zip |
4351 - Move _close & close to FileUtil.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IcePatch2/FileServerI.cpp | 18 | ||||
-rw-r--r-- | cpp/src/IcePatch2Lib/Util.cpp | 31 | ||||
-rw-r--r-- | cpp/src/IceUtil/FileUtil.cpp | 16 |
3 files changed, 24 insertions, 41 deletions
diff --git a/cpp/src/IcePatch2/FileServerI.cpp b/cpp/src/IcePatch2/FileServerI.cpp index 858eb449a6e..30235000b62 100644 --- a/cpp/src/IcePatch2/FileServerI.cpp +++ b/cpp/src/IcePatch2/FileServerI.cpp @@ -108,11 +108,7 @@ IcePatch2::FileServerI::getFileCompressed_async(const AMD_FileServer_getFileComp #endif != static_cast<off_t>(pos)) { -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - _close(fd); -#else - close(fd); -#endif + IceUtilInternal::close(fd); ostringstream posStr; posStr << pos; @@ -138,11 +134,7 @@ IcePatch2::FileServerI::getFileCompressed_async(const AMD_FileServer_getFileComp 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 + IceUtilInternal::close(fd); FileAccessException ex; ex.reason = "cannot read `" + path + "': " + strerror(errno); @@ -150,11 +142,7 @@ IcePatch2::FileServerI::getFileCompressed_async(const AMD_FileServer_getFileComp return; } -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - _close(fd); -#else - close(fd); -#endif + IceUtilInternal::close(fd); ret.first = bytes.get(); ret.second = ret.first + r; diff --git a/cpp/src/IcePatch2Lib/Util.cpp b/cpp/src/IcePatch2Lib/Util.cpp index e8699073978..0aeb63fbbf6 100644 --- a/cpp/src/IcePatch2Lib/Util.cpp +++ b/cpp/src/IcePatch2Lib/Util.cpp @@ -1085,11 +1085,7 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G stdioFile = IceUtilInternal::fopen(simplify(pathBZ2Temp), "wb"); if(!stdioFile) { -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - _close(fd); -#else - close(fd); -#endif + IceUtilInternal::close(fd); throw "cannot open `" + pathBZ2Temp + "' for writing:\n" + IceUtilInternal::lastErrorToString(); } @@ -1102,11 +1098,7 @@ 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 + IceUtilInternal::close(fd); throw ex; } } @@ -1130,12 +1122,7 @@ 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 + IceUtilInternal::close(fd); throw "cannot read from `" + path + "':\n" + IceUtilInternal::lastErrorToString(); } bytesLeft -= static_cast<unsigned int>(bytes.size()); @@ -1153,11 +1140,7 @@ 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 + IceUtilInternal::close(fd); throw ex; } } @@ -1166,11 +1149,7 @@ 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 + IceUtilInternal::close(fd); #ifndef __BCPLUSPLUS__ if(doCompress) diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index f5254c6a38e..67f1569fdc0 100644 --- a/cpp/src/IceUtil/FileUtil.cpp +++ b/cpp/src/IceUtil/FileUtil.cpp @@ -162,6 +162,16 @@ IceUtilInternal::unlink(const string& path) return _wunlink(IceUtil::stringToWstring(path).c_str()); } +int +IceUtilInternal::close(int fd) +{ +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + return _close(fd); +#else + return ::close(fd); +#endif +} + #ifdef _STLP_BEGIN_NAMESPACE namespace { @@ -391,6 +401,12 @@ IceUtilInternal::unlink(const string& path) return ::unlink(path.c_str()); } +int +IceUtilInternal::close(int fd) +{ + return ::close(fd); +} + IceUtilInternal::ifstream::ifstream() { } |