Skip to content

Commit

Permalink
Use correct TMP dir on macOS (#513)
Browse files Browse the repository at this point in the history
IB-7606

Signed-off-by: Raul Metsma <raul@metsma.ee>

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma authored Dec 15, 2022
1 parent f7267a8 commit 9502e6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

6. Alternative to steps 4. and 5. -

powershell -ExecutionPolicy ByPass -File build.ps1 -toolset 141
powershell -ExecutionPolicy ByPass -File build.ps1 -toolset 142

The build script builds executables and installation media for all
platforms (x86 and x64 / Debug and Release with debug symbols)
Expand Down
14 changes: 9 additions & 5 deletions src/util/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,19 @@ string File::tempFileName()
#ifdef _WIN32
// requires TMP environment variable to be set
wchar_t *fileName = _wtempnam(nullptr, nullptr); // TODO: static buffer, not thread-safe
if ( !fileName )
if(!fileName)
THROW("Failed to create a temporary file name.");
string path = decodeName(fileName);
free(fileName);
#else
#ifdef __APPLE__
string path = env("TMPDIR") + "/XXXXXX";
#else
char *fileName = strdup("/tmp/XXXXXX");
if (mkstemp(fileName) == -1)
string path = "/tmp/XXXXXX";
#endif
if(mkstemp(path.data()) == -1)
THROW("Failed to create a temporary file name.");
#endif
string path = decodeName(fileName);
free(fileName);
tempFiles.push(path);
return path;
}
Expand Down

0 comments on commit 9502e6c

Please sign in to comment.