blob: 9d52ecd9559d412a2cb2b3d8dee8134b537d3b22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// --------------------------------------------------------------------------
//
// File
// Name: TemporaryDirectory.h
// Purpose: Location of temporary directory
// Created: 2003/10/13
//
// --------------------------------------------------------------------------
#ifndef TEMPORARYDIRECTORY__H
#define TEMPORARYDIRECTORY__H
#include <string>
#ifdef WIN32
#include <windows.h>
#endif
// Prefix name with Box to avoid clashing with OS API names
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
}
#endif // TEMPORARYDIRECTORY__H
|