Skip to content

Commit

Permalink
Allow to move file pointer in append mode as well
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Apr 30, 2022
1 parent c08837d commit b33d31c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions System/File/AbstractFilePath/Windows.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import System.AbstractFilePath.Windows ( WindowsFilePath )

import qualified System.Win32 as Win32
import qualified System.Win32.WindowsString.File as WS
import Control.Monad (when, void)
#if defined(__IO_MANAGER_WINIO__)
import GHC.IO.SubSystem
#endif
Expand All @@ -31,12 +32,15 @@ openFile fp iomode = bracketOnError
#endif
Nothing)
Win32.closeHandle
Win32.hANDLEToHandle
toHandle
where
toHandle h = do
when (iomode == AppendMode ) $ void $ Win32.setFilePointerEx h 0 Win32.fILE_END
Win32.hANDLEToHandle h
accessMode = case iomode of
ReadMode -> Win32.gENERIC_READ
WriteMode -> Win32.gENERIC_WRITE
AppendMode -> Win32.fILE_APPEND_DATA
AppendMode -> Win32.gENERIC_WRITE .|. Win32.fILE_APPEND_DATA
ReadWriteMode -> Win32.gENERIC_READ .|. Win32.gENERIC_WRITE

createMode = case iomode of
Expand Down

0 comments on commit b33d31c

Please sign in to comment.