From 2a37e107a5e49e6062454059c99ea54d52f76c9a Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 10 Aug 2024 19:27:56 +0800 Subject: [PATCH 1/2] Add GHC-8.10 for windows --- .github/workflows/test.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ce1c268..4877fe4 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - ghc: ['8.8', '8.10', '9.0', '9.2', '9.4', '9.6', '9.8'] + ghc: ['8.8', '8.10', '9.0', '9.2', '9.4', '9.6', '9.8', '9.10'] include: - os: macOS-latest ghc: '9.4' @@ -24,6 +24,8 @@ jobs: ghc: '9.6' - os: macOS-latest ghc: '9.8' + - os: windows-latest + ghc: '8.10' - os: windows-latest ghc: '9.4' - os: windows-latest From 1204e8b1063199e7ff205180f5bbb2e7424fc304 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 10 Aug 2024 19:21:27 +0800 Subject: [PATCH 2/2] Fix support for GHC =< 8.10 --- windows/System/File/Platform.hsc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/windows/System/File/Platform.hsc b/windows/System/File/Platform.hsc index 02bdafc..f25800b 100644 --- a/windows/System/File/Platform.hsc +++ b/windows/System/File/Platform.hsc @@ -102,7 +102,7 @@ writeShareMode = Win32.fILE_SHARE_DELETE .|. Win32.fILE_SHARE_READ - -- | Open an existing file and return the 'Handle'. +-- | Open an existing file and return the 'Handle'. openExistingFile :: WindowsPath -> IOMode -> IO Handle openExistingFile fp iomode = bracketOnError (WS.createFile @@ -168,6 +168,7 @@ findTempName (prefix, suffix) loc tmp_dir mode = go #endif withTString label $ \c_template -> withTString suffix $ \c_suffix -> +#if MIN_VERSION_base(4, 15, 0) with nullPtr $ \c_ptr -> do res <- c_createUUIDTempFileErrNo c_tmp_dir c_template c_suffix c_ptr if not res @@ -178,13 +179,31 @@ findTempName (prefix, suffix) loc tmp_dir mode = go free c_p let flags = fromIntegral mode .&. o_EXCL handleResultsWinIO filename (flags == o_EXCL) +#else + -- NOTE: revisit this when new I/O manager in place and use a UUID + -- based one when we are no longer MAX_PATH bound. + allocaBytes (sizeOf (undefined :: CWchar) * 260) $ \c_str -> do + res <- c_getTempFileNameErrorNo c_tmp_dir c_template c_suffix 0 + c_str + if not res + then do errno <- getErrno + ioError (errnoToIOError loc errno Nothing (Just $ lenientDecode tmp_dir)) + else do filename <- peekTString c_str + let flags = fromIntegral mode .&. o_EXCL + handleResultsWinIO filename (flags == o_EXCL) +#endif handleResultsWinIO filename excl = do h <- (if excl then openExistingFile else openFile) filename ReadWriteMode return (filename, h) +#if MIN_VERSION_base(4, 15, 0) foreign import ccall "__createUUIDTempFileErrNo" c_createUUIDTempFileErrNo :: CWString -> CWString -> CWString -> Ptr CWString -> IO Bool +#else +foreign import ccall "getTempFileNameErrorNo" c_getTempFileNameErrorNo + :: CWString -> CWString -> CWString -> CUInt -> Ptr CWchar -> IO Bool +#endif