在 OCaml 中创建一个 tar 文件

Create a tar file in OCaml

如何在 OCaml 中 create/write 一个 TAR 文件?我知道有 ocaml_tar 模块,但我找不到任何关于如何 create/write 一个 TAR 文件的例子。我如何在 OCaml 中做到这一点?

解决方法是使用 Linux 的现有 tar 工具或 Windows 中的相关工具。例如,tar -zcvf data.tgz *.doc

并且您可以使用 Sys 库中的函数来创建对工具 tar 的系统调用。

Archive.create to create an archive on a file descriptor (if you want to create a file, use Unix.openfile), to read a file, you have with_next_filefd f where the callback f should use the Header.t to know the length of the data to read. If you just want to extract the content to files, just use extract.