Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

append files to an archive without reading/rewriting the whole archive

Tags:

java

archive

tar

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. 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.

What other archive format would you suggest that allows fast append operations?

like image 469
Benedikt Waldvogel Avatar asked Jun 07 '10 23:06

Benedikt Waldvogel


2 Answers

The ZIP file format was designed to allow appends without a total re-write and is ubiquitous, even on Unix.

like image 65
msw Avatar answered Sep 28 '22 06:09

msw


ZIP and TAR fomats (and the old AR format) allow file append without a full rewrite. However:

  • The Java archive classes DO NOT support this mode of operation.
  • 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. 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.
like image 21
Stephen C Avatar answered Sep 28 '22 08:09

Stephen C