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
)