diff options
author | Chris Wilson <chris+github@qwirx.com> | 2011-01-21 20:16:13 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2011-01-21 20:16:13 +0000 |
commit | 8766a03cc950912b4cd8f60aa63061a0059c6885 (patch) | |
tree | a6408bb3373bc9a10d30dc12fea492edeb72f21c /lib/common/Utils.cpp | |
parent | 1f1219b2339abcac71621516358683220789287e (diff) |
Move TemporaryDirectory.h into Utils.h and Utils.cpp to avoid duplicate
definitions of inline functions.
Diffstat (limited to 'lib/common/Utils.cpp')
-rw-r--r-- | lib/common/Utils.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/common/Utils.cpp b/lib/common/Utils.cpp index 6afafe84..4f44ce0a 100644 --- a/lib/common/Utils.cpp +++ b/lib/common/Utils.cpp @@ -335,3 +335,31 @@ std::string FormatUsageLineStart(const std::string& rName, return result.str(); } + +std::string BoxGetTemporaryDirectoryName() +{ +#ifdef WIN32 + // http://msdn.microsoft.com/library/default.asp? + // url=/library/en-us/fileio/fs/creating_and_using_a_temporary_file.asp + + DWORD dwRetVal; + char lpPathBuffer[1024]; + DWORD dwBufSize = sizeof(lpPathBuffer); + + // Get the temp path. + dwRetVal = GetTempPath(dwBufSize, // length of the buffer + lpPathBuffer); // buffer for path + if (dwRetVal > dwBufSize) + { + THROW_EXCEPTION(CommonException, TempDirPathTooLong) + } + + return std::string(lpPathBuffer); +#elif defined TEMP_DIRECTORY_NAME + return std::string(TEMP_DIRECTORY_NAME); +#else + #error non-static temporary directory names not supported yet +#endif +} + + |