diff options
author | Michi Henning <michi@zeroc.com> | 2005-11-17 21:13:27 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2005-11-17 21:13:27 +0000 |
commit | ffcd9c840d39824b142e195f90115a77be533b2b (patch) | |
tree | 45238ee8f905d7112a38b7369cc13886160ff9eb /cpp/src/Ice/Instance.cpp | |
parent | Removed warning from VS 8. (diff) | |
download | ice-ffcd9c840d39824b142e195f90115a77be533b2b.tar.bz2 ice-ffcd9c840d39824b142e195f90115a77be533b2b.tar.xz ice-ffcd9c840d39824b142e195f90115a77be533b2b.zip |
Fixed VS 8 warning.
Diffstat (limited to 'cpp/src/Ice/Instance.cpp')
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index b7ee0a20fbf..2b1ce673e23 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -413,6 +413,34 @@ IceInternal::Instance::getDefaultContext() const return _defaultContext; } +static FILE* +freopenP(const char* path, const char* mode, FILE* stream) +{ + FILE* file; + +#if _WIN32 && _MSC_VER >= 1400 + ::freopen_s(&file, path, mode, stream); + if(file == 0) + { + FileException ex(__FILE__, __LINE__); + ex.path = path; + char buf[1024]; + ex.error = _strerror_s(buf, sizeof(buf), "freopen_s failed"); + throw ex; + } +#else + file = ::freopen(path, mode, stream); + if(file == 0) + { + FileException ex(__FILE__, __LINE__); + ex.path = path; + ex.error = getSystemErrno(); + throw ex; + } +#endif + + return file; +} IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const PropertiesPtr& properties, const LoggerPtr& logger) : @@ -442,26 +470,15 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Prope if(stdOutFilename != "") { - FILE* file = freopen(stdOutFilename.c_str(), "a", stdout); - if(file == 0) - { - FileException ex(__FILE__, __LINE__); - ex.path = stdOutFilename; - ex.error = getSystemErrno(); - throw ex; - } + FILE* file; +#ifdef _WIN32 + file = freopenP(stdOutFilename.c_str(), "a", stdout); +#endif } if(stdErrFilename != "") { - FILE* file = freopen(stdErrFilename.c_str(), "a", stderr); - if(file == 0) - { - FileException ex(__FILE__, __LINE__); - ex.path = stdErrFilename; - ex.error = getSystemErrno(); - throw ex; - } + FILE* file = freopenP(stdErrFilename.c_str(), "a", stderr); } unsigned int seed = static_cast<unsigned int>(IceUtil::Time::now().toMicroSeconds()); @@ -895,6 +912,6 @@ IceInternal::Instance::destroy() if(serverThreadPool) { serverThreadPool->joinWithAllThreads(); - }
+ } return true; } |