summaryrefslogtreecommitdiff
path: root/libraries/base/cbits
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2020-06-08 07:56:30 +0100
committerBen Gamari <ben@smart-cactus.org>2020-07-15 16:41:03 -0400
commit8b8405a0dd45c16ec305884cadda992327733621 (patch)
tree19c77bcc7719c26a1f1a22896835476e4cd4a05e /libraries/base/cbits
parent16bab48ef69866725d2ab20ca7bd1da5f5a70000 (diff)
downloadhaskell-8b8405a0dd45c16ec305884cadda992327733621.tar.gz
winio: update temp path so GCC etc can handle it.
Also fix PIPE support, clean up error casting, fix memory leaks
Diffstat (limited to 'libraries/base/cbits')
-rw-r--r--libraries/base/cbits/Win32Utils.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libraries/base/cbits/Win32Utils.c b/libraries/base/cbits/Win32Utils.c
index 345e46811b..e886cceb9f 100644
--- a/libraries/base/cbits/Win32Utils.c
+++ b/libraries/base/cbits/Win32Utils.c
@@ -183,15 +183,22 @@ bool __createUUIDTempFileErrNo (wchar_t* pathName, wchar_t* prefix,
if (UuidToStringW ((UUID*)&guid, &guidStr) != S_OK)
goto fail;
- wchar_t* devName = FS(create_device_name) ((wchar_t*)pathName);
+ /* We can't create a device path here since this path escapes the compiler
+ so instead return a normal path and have openFile deal with it. */
+ wchar_t* devName = malloc (sizeof (wchar_t) * wcslen (pathName));
+ wcscpy (devName, pathName);
int len = wcslen (devName) + wcslen (suffix) + wcslen (prefix)
+ wcslen (guidStr) + 3;
*tempFileName = malloc (len * sizeof (wchar_t));
if (*tempFileName == NULL)
goto fail;
- if (-1 == swprintf_s (*tempFileName, len, L"%ls\\%ls-%ls%ls",
- devName, prefix, guidStr, suffix))
+ /* Only add a slash if path didn't already end in one, otherwise we create
+ an invalid path. */
+ bool slashed = devName[wcslen(devName)-1] == '\\';
+ wchar_t* sep = slashed ? L"" : L"\\";
+ if (-1 == swprintf_s (*tempFileName, len, L"%ls%ls%ls-%ls%ls",
+ devName, sep, prefix, guidStr, suffix))
goto fail;
free (devName);