Skip to content

Commit 9502e6c

Browse files
authored
Use correct TMP dir on macOS (#513)
IB-7606 Signed-off-by: Raul Metsma <[email protected]> Signed-off-by: Raul Metsma <[email protected]>
1 parent f7267a8 commit 9502e6c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117

118118
6. Alternative to steps 4. and 5. -
119119

120-
powershell -ExecutionPolicy ByPass -File build.ps1 -toolset 141
120+
powershell -ExecutionPolicy ByPass -File build.ps1 -toolset 142
121121

122122
The build script builds executables and installation media for all
123123
platforms (x86 and x64 / Debug and Release with debug symbols)

src/util/File.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,19 @@ string File::tempFileName()
362362
#ifdef _WIN32
363363
// requires TMP environment variable to be set
364364
wchar_t *fileName = _wtempnam(nullptr, nullptr); // TODO: static buffer, not thread-safe
365-
if ( !fileName )
365+
if(!fileName)
366366
THROW("Failed to create a temporary file name.");
367+
string path = decodeName(fileName);
368+
free(fileName);
369+
#else
370+
#ifdef __APPLE__
371+
string path = env("TMPDIR") + "/XXXXXX";
367372
#else
368-
char *fileName = strdup("/tmp/XXXXXX");
369-
if (mkstemp(fileName) == -1)
373+
string path = "/tmp/XXXXXX";
374+
#endif
375+
if(mkstemp(path.data()) == -1)
370376
THROW("Failed to create a temporary file name.");
371377
#endif
372-
string path = decodeName(fileName);
373-
free(fileName);
374378
tempFiles.push(path);
375379
return path;
376380
}

0 commit comments

Comments
 (0)