@@ -32,7 +32,7 @@ Author: CM Wintersteiger
32
32
#include < unistd.h>
33
33
#endif
34
34
35
- #include " invariant .h"
35
+ #include " exception_utils .h"
36
36
#include " file_util.h"
37
37
38
38
std::string get_temporary_directory (const std::string &name_template)
@@ -45,7 +45,9 @@ std::string get_temporary_directory(const std::string &name_template)
45
45
DWORD dwRetVal = GetTempPathA (dwBufSize, lpPathBuffer);
46
46
47
47
if (dwRetVal > dwBufSize || (dwRetVal == 0 ))
48
- throw " GetTempPath failed" ; // NOLINT(readability/throw)
48
+ {
49
+ throw system_exceptiont (" Couldn't get temporary path" );
50
+ }
49
51
50
52
// GetTempFileNameA produces <path>\<pre><uuuu>.TMP
51
53
// where <pre> = "TLO"
@@ -54,12 +56,18 @@ std::string get_temporary_directory(const std::string &name_template)
54
56
char t[MAX_PATH];
55
57
UINT uRetVal=GetTempFileNameA (lpPathBuffer, " TLO" , 0 , t);
56
58
if (uRetVal == 0 )
57
- throw " GetTempFileName failed" ; // NOLINT(readability/throw)
59
+ {
60
+ throw system_exceptiont (
61
+ std::string (" Couldn't get new temporary file name in directory" ) +
62
+ lpPathBuffer);
63
+ }
58
64
59
65
unlink (t);
60
- if (_mkdir (t)!=0 )
61
- throw " _mkdir failed" ;
62
-
66
+ if (_mkdir (t) != 0 )
67
+ {
68
+ throw system_exceptiont (
69
+ std::string (" Couldn't create temporary directory at " ) + t);
70
+ }
63
71
result=std::string (t);
64
72
65
73
#else
@@ -75,7 +83,7 @@ std::string get_temporary_directory(const std::string &name_template)
75
83
t.push_back (' \0 ' ); // add the zero
76
84
const char *td = mkdtemp (t.data ());
77
85
if (!td)
78
- throw " mkdtemp failed " ;
86
+ throw system_exceptiont ( " Failed to create temporary directory " ) ;
79
87
result=std::string (td);
80
88
#endif
81
89
0 commit comments