diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-08-14 12:50:35 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-08-14 12:50:35 -0230 |
commit | a7b3edad335654808ccc1dd38a0347b827c8daff (patch) | |
tree | 93f6525d8b04d156ef39cdf816242c21b7744db5 /cpp/src/Slice/Preprocessor.cpp | |
parent | fix bug with makedepend. (diff) | |
download | ice-a7b3edad335654808ccc1dd38a0347b827c8daff.tar.bz2 ice-a7b3edad335654808ccc1dd38a0347b827c8daff.tar.xz ice-a7b3edad335654808ccc1dd38a0347b827c8daff.zip |
Changed preprocess to write tmpfile to tmp directory.
Diffstat (limited to 'cpp/src/Slice/Preprocessor.cpp')
-rw-r--r-- | cpp/src/Slice/Preprocessor.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 763b8a7a855..b9fb132092f 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -176,18 +176,32 @@ Slice::Preprocessor::preprocess(bool keepComments) // char* buf = mcpp_get_mem_buffer(Out); - _cppFile = ".preprocess." + IceUtil::generateUUID(); - SignalHandler::addFile(_cppFile); #ifdef _WIN32 + TCHAR buffer[512]; + DWORD ret = GetTempPath(512, buffer); + if(ret > 512 || ret == 0) + { + fprintf(stderr, "GetTempPath failed (%d)\n", GetLastError()); + } + _cppFile = string(buffer) + "\\.preprocess." + IceUtil::generateUUID(); _cppHandle = ::_wfopen(IceUtil::stringToWstring(_cppFile).c_str(), IceUtil::stringToWstring("w+").c_str()); #else + _cppFile = "/tmp/.preprocess." + IceUtil::generateUUID(); _cppHandle = ::fopen(_cppFile.c_str(), "w+"); #endif - if(buf) + if(_cppHandle != NULL) + { + SignalHandler::addFile(_cppFile); + if(buf) + { + ::fwrite(buf, strlen(buf), 1, _cppHandle); + } + ::rewind(_cppHandle); + } + else { - ::fwrite(buf, strlen(buf), 1, _cppHandle); + fprintf(stderr, "Could not open temporary file: %s\n", _cppFile.c_str()); } - ::rewind(_cppHandle); } // |