Skip to content

Commit

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

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Dec 9, 2022
1 parent 0bc9978 commit 527443e
Showing 1 changed file with 9 additions and 5 deletions.
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 527443e

Please sign in to comment.