Skip to content

Commit b2e7a52

Browse files
committed
Merge branch 'fix-ghc-8.10'
2 parents 5ab65c4 + 1204e8b commit b2e7a52

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
os: [ubuntu-latest]
19-
ghc: ['8.8', '8.10', '9.0', '9.2', '9.4', '9.6', '9.8']
19+
ghc: ['8.8', '8.10', '9.0', '9.2', '9.4', '9.6', '9.8', '9.10']
2020
include:
2121
- os: macOS-latest
2222
ghc: '9.4'
2323
- os: macOS-latest
2424
ghc: '9.6'
2525
- os: macOS-latest
2626
ghc: '9.8'
27+
- os: windows-latest
28+
ghc: '8.10'
2729
- os: windows-latest
2830
ghc: '9.4'
2931
- os: windows-latest

windows/System/File/Platform.hsc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ writeShareMode =
102102
Win32.fILE_SHARE_DELETE .|.
103103
Win32.fILE_SHARE_READ
104104

105-
-- | Open an existing file and return the 'Handle'.
105+
-- | Open an existing file and return the 'Handle'.
106106
openExistingFile :: WindowsPath -> IOMode -> IO Handle
107107
openExistingFile fp iomode = bracketOnError
108108
(WS.createFile
@@ -168,6 +168,7 @@ findTempName (prefix, suffix) loc tmp_dir mode = go
168168
#endif
169169
withTString label $ \c_template ->
170170
withTString suffix $ \c_suffix ->
171+
#if MIN_VERSION_base(4, 15, 0)
171172
with nullPtr $ \c_ptr -> do
172173
res <- c_createUUIDTempFileErrNo c_tmp_dir c_template c_suffix c_ptr
173174
if not res
@@ -178,13 +179,31 @@ findTempName (prefix, suffix) loc tmp_dir mode = go
178179
free c_p
179180
let flags = fromIntegral mode .&. o_EXCL
180181
handleResultsWinIO filename (flags == o_EXCL)
182+
#else
183+
-- NOTE: revisit this when new I/O manager in place and use a UUID
184+
-- based one when we are no longer MAX_PATH bound.
185+
allocaBytes (sizeOf (undefined :: CWchar) * 260) $ \c_str -> do
186+
res <- c_getTempFileNameErrorNo c_tmp_dir c_template c_suffix 0
187+
c_str
188+
if not res
189+
then do errno <- getErrno
190+
ioError (errnoToIOError loc errno Nothing (Just $ lenientDecode tmp_dir))
191+
else do filename <- peekTString c_str
192+
let flags = fromIntegral mode .&. o_EXCL
193+
handleResultsWinIO filename (flags == o_EXCL)
194+
#endif
181195

182196
handleResultsWinIO filename excl = do
183197
h <- (if excl then openExistingFile else openFile) filename ReadWriteMode
184198
return (filename, h)
185199

200+
#if MIN_VERSION_base(4, 15, 0)
186201
foreign import ccall "__createUUIDTempFileErrNo" c_createUUIDTempFileErrNo
187202
:: CWString -> CWString -> CWString -> Ptr CWString -> IO Bool
203+
#else
204+
foreign import ccall "getTempFileNameErrorNo" c_getTempFileNameErrorNo
205+
:: CWString -> CWString -> CWString -> CUInt -> Ptr CWchar -> IO Bool
206+
#endif
188207

189208

190209

0 commit comments

Comments
 (0)