diff --git a/System/Directory/Internal/Prelude.hs b/System/Directory/Internal/Prelude.hs index 8ac315c70edbfa3d7888ae2fd6928f106b7dfcc5..c5843b032b53c13e4166deccb6636d1012d0c0d6 100644 --- a/System/Directory/Internal/Prelude.hs +++ b/System/Directory/Internal/Prelude.hs @@ -129,6 +129,7 @@ import Foreign.C import GHC.IO.Exception ( IOErrorType ( InappropriateType + , InvalidArgument , OtherError , UnsupportedOperation ) diff --git a/System/Directory/Internal/Windows.hsc b/System/Directory/Internal/Windows.hsc index d0ab3794793cddc51008de86265550587aa5a999..fc5de0c3ffbd72ae26b8586f99f189d0cb82ccbf 100644 --- a/System/Directory/Internal/Windows.hsc +++ b/System/Directory/Internal/Windows.hsc @@ -579,10 +579,14 @@ setTimes :: FilePath -> (Maybe POSIXTime, Maybe POSIXTime) -> IO () setTimes path' (atime', mtime') = bracket (openFileHandle path' Win32.gENERIC_WRITE) Win32.closeHandle $ \ handle -> +#if MIN_VERSION_Win32(2,12,0) + Win32.setFileTime handle Nothing (posixToWindowsTime <$> atime') (posixToWindowsTime <$> mtime') +#else maybeWith with (posixToWindowsTime <$> atime') $ \ atime'' -> maybeWith with (posixToWindowsTime <$> mtime') $ \ mtime'' -> Win32.failIf_ not "" $ Win32.c_SetFileTime handle nullPtr atime'' mtime'' +#endif -- | Open the handle of an existing file or directory. openFileHandle :: String -> Win32.AccessMode -> IO Win32.HANDLE diff --git a/directory.cabal b/directory.cabal index 916c5ce5f735e5570d42e155111ac0818eea7c3e..44937cd3cc55fd8da36d02b04f12cfcb786af661 100644 --- a/directory.cabal +++ b/directory.cabal @@ -58,7 +58,7 @@ Library time >= 1.4 && < 1.12, filepath >= 1.3 && < 1.5 if os(windows) - build-depends: Win32 >= 2.2.2 && < 2.12 + build-depends: Win32 >= 2.2.2 && < 2.13 else build-depends: unix >= 2.5.1 && < 2.9 diff --git a/tests/CreateDirectoryIfMissing001.hs b/tests/CreateDirectoryIfMissing001.hs index b89f361d98842af6609d7451da10e8b1699f6b54..c16db6f853fe462084fe9043f5d8e6330520f999 100644 --- a/tests/CreateDirectoryIfMissing001.hs +++ b/tests/CreateDirectoryIfMissing001.hs @@ -81,7 +81,10 @@ main _t = do -- (see bug #2924 on GHC Trac) create = createDirectoryIfMissing True testdir_a `catch` \ e -> - if isDoesNotExistError e || isPermissionError e || isInappropriateTypeError e + if isDoesNotExistError e + || isPermissionError e + || isInappropriateTypeError e + || ioeGetErrorType e == InvalidArgument then return () else ioError e