简体   繁体   English

将文件附加到存档而不读取/重写整个存档

[英]append files to an archive without reading/rewriting the whole archive

I've got many files that I want to store in a single archive file. 我有很多文件要存储在一个存档文件中。 My first approach was to store the files in a gzipped tarball. 我的第一种方法是将文件存储在一个gzip压缩包中。 The problem is, that I've to rewrite the whole archive if a single file is added. 问题是,如果添加单个文件,我将重写整个存档。 I could get rid of the gzip compression, but adding a file would still be expensive. 我可以摆脱gzip压缩,但添加文件仍然很昂贵。

What other archive format would you suggest that allows fast append operations? 您会建议哪种其他存档格式允许快速追加操作?

ZIP文件格式旨在允许附加而无需完全重写,并且无处不在,即使在Unix上也是如此。

ZIP and TAR fomats (and the old AR format) allow file append without a full rewrite. ZIP和TAR fomats(以及旧的AR格式)允许文件附加而不进行完全重写。 However: 然而:

  • The Java archive classes DO NOT support this mode of operation. Java归档类不支持此操作模式。
  • File append is likely to result in multiple copies of a file in the archive if you append an existing file. 如果附加现有文件,文件追加可能会导致存档中文件的多个副本。
  • The ZIP and AR formats have a directory that needs to be rewritten following a file append operation. ZIP和AR格式有一个目录,需要在文件追加操作后重写。 The standard utilities take precautions when rewriting the directory, but it is possible in theory that you may end up with an archive with a missing or corrupted directory if the append fails. 标准实用程序在重写目录时会采取预防措施,但理论上如果附加失败,最终可能会导致目录丢失或损坏的存档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM