Skip to content

Commit d21cf4b

Browse files
committed
Use stdlib temp path for tests
For some reason the existing one doesn't provide a good result in some Linux machines.
1 parent 469943e commit d21cf4b

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

LiteCore/Support/TestsCommon.cc

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <fstream>
2323
#include <mutex>
2424
#include <thread>
25+
#include <filesystem>
2526

2627
#ifdef _MSC_VER
2728
# include <atlbase.h>
@@ -34,20 +35,6 @@ using namespace std;
3435
using namespace litecore;
3536
using namespace fleece;
3637

37-
FilePath GetSystemTempDirectory() {
38-
#ifdef _MSC_VER
39-
WCHAR pathBuffer[MAX_PATH + 1];
40-
GetTempPathW(MAX_PATH, pathBuffer);
41-
GetLongPathNameW(pathBuffer, pathBuffer, MAX_PATH);
42-
CW2AEX<256> convertedPath(pathBuffer, CP_UTF8);
43-
return litecore::FilePath(convertedPath.m_psz);
44-
#else // _MSC_VER
45-
const char* tmp = getenv("TMPDIR");
46-
if ( !tmp ) tmp = "/tmp";
47-
return {tmp};
48-
#endif // _MSC_VER
49-
}
50-
5138
FilePath GetTempDirectory() {
5239
static FilePath kTempDir;
5340
static once_flag f;
@@ -56,7 +43,7 @@ FilePath GetTempDirectory() {
5643
char folderName[bufSize];
5744
snprintf(folderName, bufSize, "LiteCore_Tests_%" PRIms ".cblite2/",
5845
chrono::milliseconds(time(nullptr)).count());
59-
kTempDir = GetSystemTempDirectory()[folderName];
46+
kTempDir = filesystem::temp_directory_path() / folderName;
6047
(void)kTempDir.mkdir(); // it's OK if it already exists
6148
});
6249

0 commit comments

Comments
 (0)