开发者

TrueZip creates virtual directory instead of archive

I'm having an issue with the following code:

    TFile src = new TFile(this.getMellomStasjon());
    TFile dst = new TFile(this.getZipFolder()+""+zipFile+".zip");
    if(dst.isDirectory())
        dst = new TFile(dst, src.getName());

    TFile.cp_rp(src, dst, null);
    TFile file = newNonArchiveFile(dst);
    if(dst.isArchive())
        TFile.umount(dst);
开发者_运维技巧

My goal is to put a directory containing files into a ZIP-archive using TrueZip. The problem is that the code works locally but not on the production computer. Locally I get a single ZIP-file, but in production I get a folder containing the files I'm trying to put in the archive (virtual directory). I have to use TrueZip because I'm archiving content over 4GB.

Is there any way to force TrueZip to create an archive instead of a (virtual) directory?


It probably didn't work because the JAR artifact of the module TrueZIP Driver ZIP was not present on the run time class path.

To make sure it is, you could make the ZipDriver a compile time dependency by setting a custom TArchiveDetector. Here is an example: http://truezip.java.net/usecases/aff.html

The code you show here is problematic. You should probably fix it to:

// Call this once at application startup to make the ZipDriver a compile time
// dependency.
TFile.setDefaultArchiveDetector(
  new TArchiveDetector(
  "zip",
  new ZipDriver(IOPoolLocator.SINGLETON)));

// Here's the work.
TFile src = new TFile(this.getMellomStasjon());
TFile dst = new TFile(this.getZipFolder(), zipFile + ".zip");
TFile.cp_rp(src, dst, TArchiveDetector.NULL);
TFile.umount(dst);


Found an alternative library by Apache, Commons Compression. Using it instead of TrueZip. Seems to support >4gb files as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜