Skip to content

Commit 5ca4814

Browse files
sbalujaJinjin.He
andauthored
Pr/3551 - MinGW test failure fixes (#3555)
* fix tmpnam_s call error while using MinGW * fix CreateDirectoryIfNotExists trim fault about drive letter while using MinGW * FileSystem.cpp - Fix MinGW version check to check for definition first --------- Co-authored-by: Jinjin.He <[email protected]>
1 parent 3d6e7ab commit 5ca4814

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ bool CreateDirectoryIfNotExists(const char* path, bool createParentDirs)
218218
for (size_t i = createParentDirs ? 0 : directoryName.size() - 1; i < directoryName.size(); i++)
219219
{
220220
// Create the intermediate directory if we find a delimiter and the delimiter is not the first char, or if this is the target directory.
221-
if (i != 0 && (directoryName[i] == FileSystem::PATH_DELIM || i == directoryName.size() - 1))
221+
if (i > 2 && (directoryName[i] == FileSystem::PATH_DELIM || i == directoryName.size() - 1))
222222
{
223223
// the last delimeter can be removed safely.
224224
if (directoryName[i] == FileSystem::PATH_DELIM)
@@ -317,6 +317,11 @@ Aws::String CreateTempFilePath()
317317
// Definition from the MSVC stdio.h
318318
#define L_tmpnam_s (sizeof("\\") + 16)
319319
#endif
320+
321+
#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 12
322+
#undef L_tmpnam_s
323+
#define L_tmpnam_s 260
324+
#endif
320325
char s_tempName[L_tmpnam_s+1];
321326

322327
/*
@@ -328,7 +333,7 @@ Aws::String CreateTempFilePath()
328333
for more details.
329334
*/
330335

331-
#if _MSC_VER >= 1900
336+
#if _MSC_VER >= 1900 || defined(_UCRT)
332337
tmpnam_s(s_tempName, L_tmpnam_s);
333338
#else
334339
s_tempName[0] = '.';

0 commit comments

Comments
 (0)