1

I have destination directory on windows with "append only" permission. I want to copy file to it and I want to preserve modification time. Next code makes copy but than crashes:

import qualified Data.ByteString.Lazy  as BS
withBinaryFile destPath WriteMode (\h -> do
     hSetBinaryMode h True
     BS.readFile sourcePath >>= BS.hPut h
   )
-- next line crashes due to permission
getModificationTime sourcePath >>= setModificationTime destPath

The next code would be better, but the function hSetModificationTime does not exists

import qualified Data.ByteString.Lazy  as BS
withBinaryFile destPath WriteMode (\h -> do
     hSetBinaryMode h True
     BS.readFile sourcePath >>= BS.hPut h
                                        -- not existing function 
     getModificationTime sourcePath >>= hSetModificationTime h

   )
  • [copyFileWithMetadata](https://hackage.haskell.org/package/directory-1.3.3.1/docs/System-Directory.html#v:copyFileWithMetadata), perhaps? – Daniel Wagner Sep 12 '18 at 12:44

0 Answers0