From a573cf1204efdce44d351e9b06419b2071d09982 Mon Sep 17 00:00:00 2001 From: Steffen Schuemann Date: Tue, 14 May 2019 08:05:00 +0200 Subject: [PATCH] Work on CI support for MingW --- include/ghc/filesystem.hpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index aa8a6a5..c8d53ee 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -1567,18 +1567,17 @@ GHC_INLINE path resolveSymlink(const path& p, std::error_code& ec) return path(); } - char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE] = {0}; - REPARSE_DATA_BUFFER& reparseData = *reinterpret_cast((void*)buffer); + std::shared_ptr reparseData((REPARSE_DATA_BUFFER*)std::calloc(1, MAXIMUM_REPARSE_DATA_BUFFER_SIZE), std::free); ULONG bufferUsed; path result; - if (DeviceIoControl(file.get(), FSCTL_GET_REPARSE_POINT, 0, 0, &reparseData, sizeof(buffer), &bufferUsed, 0)) { - if (IsReparseTagMicrosoft(reparseData.ReparseTag)) { - switch (reparseData.ReparseTag) { + if (DeviceIoControl(file.get(), FSCTL_GET_REPARSE_POINT, 0, 0, reparseData.get(), MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bufferUsed, 0)) { + if (IsReparseTagMicrosoft(reparseData->ReparseTag)) { + switch (reparseData->ReparseTag) { case IO_REPARSE_TAG_SYMLINK: - result = std::wstring(&reparseData.SymbolicLinkReparseBuffer.PathBuffer[reparseData.SymbolicLinkReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData.SymbolicLinkReparseBuffer.PrintNameLength / sizeof(WCHAR)); + result = std::wstring(&reparseData->SymbolicLinkReparseBuffer.PathBuffer[reparseData->SymbolicLinkReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData->SymbolicLinkReparseBuffer.PrintNameLength / sizeof(WCHAR)); break; case IO_REPARSE_TAG_MOUNT_POINT: - result = std::wstring(&reparseData.MountPointReparseBuffer.PathBuffer[reparseData.MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData.MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)); + result = std::wstring(&reparseData->MountPointReparseBuffer.PathBuffer[reparseData->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR)], reparseData->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)); break; default: break;