This issue is referred upstream from [https://github.com/Gabriella439/turtle/issues/35].
Gabriel Gonzalez's Turtle program calls Filesystem.getModified to find the modification time of a file. This works OK under Windows unless the "file" is a directory. In this case, the Windows createFile will fail because Windows attempts to open the directory. As explained on MSDN, a zero parameter should be used instead of Win32.gENERIC_READ to access directory metadata (see [https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx]) in the following code:
#ifdef CABAL_OS_WINDOWS
withHANDLE :: FilePath -> (Win32.HANDLE -> IO a) -> IO a
withHANDLE path = Exc.bracket open close where
open = Win32.createFile
(encodeString path)
Win32.gENERIC_READ
(Win32.fILE_SHARE_READ .|. Win32.fILE_SHARE_WRITE)
Nothing
Win32.oPEN_EXISTING
0
Nothing
close = Win32.closeHandle
I don't know if the code with the zero parameter will work correctly on files. It may be necessary to try the code with a zero parameter first and then try again with Win32.gENERIC_READ if the file is not a directory.
This issue is referred upstream from [https://github.com/Gabriella439/turtle/issues/35].
Gabriel Gonzalez's Turtle program calls
Filesystem.getModifiedto find the modification time of a file. This works OK under Windows unless the "file" is a directory. In this case, the WindowscreateFilewill fail because Windows attempts to open the directory. As explained on MSDN, a zero parameter should be used instead ofWin32.gENERIC_READto access directory metadata (see [https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx]) in the following code:I don't know if the code with the zero parameter will work correctly on files. It may be necessary to try the code with a zero parameter first and then try again with
Win32.gENERIC_READif the file is not a directory.