From a7b3edad335654808ccc1dd38a0347b827c8daff Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Thu, 14 Aug 2008 12:50:35 -0230 Subject: Changed preprocess to write tmpfile to tmp directory. --- cpp/src/Slice/Preprocessor.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'cpp/src/Slice/Preprocessor.cpp') 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); } // -- cgit v1.2.3