From f1b41a71be938b8711ee0fff0130185f512d2336 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 24 Jun 2022 16:08:08 -0400 Subject: Handling of temporary files (#2299) * #include an absolute path didn't work - because paths were taken to always be relative. * Work around windows issue with temporary file clash. * Handle the temporary file path actually creates a file. * Fix typo. * Fix typo in linux for temporary file. * Add unit test for io. Tests generateTemporary operation. --- source/core/slang-io.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/core/slang-io.cpp') diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index c11ba85e0..17cd60160 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -101,7 +101,8 @@ namespace Slang char* chars = tempFileName.prepareForAppend(count); // https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamea - // Generates a temporary file name. + // Generates a temporary file name. + // Will create a file with this name. DWORD ret = ::GetTempFileNameA(tempPath.getBuffer(), prefix.getBuffer(), 0, chars); if (ret == 0) @@ -111,6 +112,8 @@ namespace Slang tempFileName.appendInPlace(chars, ::strlen(chars)); } + SLANG_ASSERT(File::exists(tempFileName)); + outFileName = tempFileName; return SLANG_OK; } @@ -135,6 +138,8 @@ namespace Slang close(handle); outFileName = buffer.getBuffer(); + SLANG_ASSERT(File::exists(outFileName)); + return SLANG_OK; } #endif -- cgit v1.2.3