summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Preprocessor.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2008-11-20 20:06:52 -0330
committerDwayne Boone <dwayne@zeroc.com>2008-11-20 20:06:52 -0330
commit6b769b9593547928768c8000601fe818a36465d2 (patch)
tree3fff2cecafa644abaebd4c335a32006603476a3d /cpp/src/Slice/Preprocessor.cpp
parentUse fopen() instead of _wfopen() in preprocessor for windows (diff)
downloadice-6b769b9593547928768c8000601fe818a36465d2.tar.bz2
ice-6b769b9593547928768c8000601fe818a36465d2.tar.xz
ice-6b769b9593547928768c8000601fe818a36465d2.zip
Use _wtempnam on Windows to get temp file
Diffstat (limited to 'cpp/src/Slice/Preprocessor.cpp')
-rw-r--r--cpp/src/Slice/Preprocessor.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index f4f73c399dd..70eb7147894 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -161,12 +161,12 @@ Slice::Preprocessor::preprocess(bool keepComments)
// First try to open temporay file in tmp directory.
//
#ifdef _WIN32
- TCHAR buffer[512];
- DWORD ret = GetTempPath(512, buffer);
- if(ret != 0 && ret < 512)
+ wchar_t* name = _wtempnam(NULL, L".preprocess");
+ if(name)
{
- _cppFile = string(buffer) + "\\.preprocess." + IceUtil::generateUUID();
- _cppHandle = ::fopen(_cppFile.c_str(), "w+");
+ _cppFile = wstring(name);
+ free(name);
+ _cppHandle = ::_wfopen(_cppFile.c_str(), L"w+");
}
#else
_cppHandle = tmpfile();
@@ -177,8 +177,13 @@ Slice::Preprocessor::preprocess(bool keepComments)
//
if(_cppHandle == 0)
{
+#ifdef _WIN32
+ _cppFile = L".preprocess." + IceUtil::stringToWstring(IceUtil::generateUUID());
+ _cppHandle = ::_wfopen(_cppFile.c_str(), L"w+");
+#else
_cppFile = ".preprocess." + IceUtil::generateUUID();
_cppHandle = ::fopen(_cppFile.c_str(), "w+");
+#endif
}
if(_cppHandle != 0)
@@ -191,7 +196,13 @@ Slice::Preprocessor::preprocess(bool keepComments)
}
else
{
- cerr << "Could not open temporary file: " << _cppFile << endl;
+ cerr << "Could not open temporary file: ";
+#ifdef _WIN32
+ cerr << IceUtil::wstringToString(_cppFile);
+#else
+ cerr << _cppFile;
+#endif
+ cerr << endl;
}
}
@@ -464,10 +475,10 @@ Slice::Preprocessor::close()
int status = fclose(_cppHandle);
_cppHandle = 0;
- if(_cppFile != "")
+ if(_cppFile.size() != 0)
{
#ifdef _WIN32
- _unlink(_cppFile.c_str());
+ _wunlink(_cppFile.c_str());
#else
unlink(_cppFile.c_str());
#endif