TrueZip 创建虚拟目录而不是存档

发布于 2024-12-07 08:35:47 字数 552 浏览 1 评论 0原文

我遇到以下代码问题:

    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);

我的目标是使用 TrueZip 将包含文件的目录放入 ZIP 存档中。问题是代码可以在本地运行,但不能在生产计算机上运行。在本地,我得到一个 ZIP 文件,但在生产中,我得到一个文件夹,其中包含我尝试放入存档(虚拟目录)中的文件。我必须使用 TrueZip,因为我要归档超过 4GB 的内容。

有没有办法强制 TrueZip 创建存档而不是(虚拟)目录?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

‘画卷フ 2024-12-14 08:35:47

它可能不起作用,因为运行时类路径上不存在 TrueZIP Driver ZIP 模块的 JAR 工件。

为了确保这一点,您可以通过设置自定义 TArchiveDetector 使 ZipDriver 成为编译时依赖项。这是一个示例: http://truezip.java.net/usecases/aff.html

您在此处显示的代码有问题。您可能应该将其修复为:

// 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);

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);
挽心 2024-12-14 08:35:47

找到了 Apache 的替代库,Commons Compression。使用它代替 TrueZip。似乎也支持 >4GB 文件。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文