当我尝试使用ocaml_tar库创建TAR文件时,会得到一个End_of_file异常。
我的密码..。
#require "tar";;
#require "tar.unix";;
let f = Unix.openfile "test.tar" [ Unix.O_RDWR; Unix.O_CREAT ] 0o600;;
Tar_unix.Archive.create ["write_ex.ml"] f;;
Unix.close f;;
..。生成以下堆栈跟踪:
$ utop write_ex.ml
Exception: End_of_file.
Raised at file "lib/tar.ml", line 549, characters 36-47
Called from file "lib/tar.ml", line 460, characters 4-11
Called from file "stream.ml", line 149, characters 33-38
Called from file "lib/tar.ml", line 578, characters 6-28
Called from file "toplevel/toploop.ml", line 180, characters 17-56
有人知道怎么回事吗?
发布于 2016-08-29 16:32:10
你的代码没有什么问题。它实际上是Tar_unix
模块中的一个bug。output
函数不够健壮,如果写入被截断,则End_of_file
异常将失败。我已经解决了问题,你的代码运行良好。有关更多信息,请参见我的按下。
更新
PR被合并,更新的(0.5.1)版本发布到opam。升级到最新版本:
opam update
opam upgrade
通过查询opam,确保安装了最新版本(>= 0.5.1)
opam show tar-format
如果它仍然是旧的,那么强迫opam安装最新的:
opam install 'tar-format>=0.5.1'
https://stackoverflow.com/questions/39201064
复制相似问题