haskell - 如何将haskell中的文件复制到具有“仅附加”权限并保留修改时间的目录
问题描述
我在具有“仅附加”权限的 Windows 上有目标目录。我想将文件复制到它并且我想保留修改时间。下一个代码进行复制但崩溃:
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
下一个代码会更好,但是函数hSetModificationTime不存在
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
)
解决方案
推荐阅读
- android - EncryptedFile 加密什么类型的文件
- reactjs - 如何在 ReactJS 中使用上下文来更改不同函数中的属性
- apache-flink - 在 Apache Flink/Ververica CE 中添加自定义连接器
- javascript - 在javascript中更新对象属性?
- python - 将pycharm中的终端从sh改为普通
- jpa - 为什么 JPA EntityManager 会阻止代码执行?
- java - 如何检查java方法是否返回null而无需运行两次
- php - 无法使用 ShipStation API 创建订单
- jenkins - Groovy 中的 Jenkins 密码参数
- jql - Jira 查询在 JIRA 搜索中不起作用?