Skip to main content

[truezip-users] Re: Issue in copying files into existing archive using Path

  • From: Abhijeet Desai <desaiabhijeet89@...>
  • To: users@...
  • Subject: [truezip-users] Re: Issue in copying files into existing archive using Path
  • Date: Thu, 4 Jul 2013 17:53:17 +0200

Hi Christian,

Thanks for the reply.
I tried the changes you suggested, changed my code to use the current
directory too, but I am still facing the same issue.

    TConfig current = TConfig.get();
    TArchiveDetector tArchiveDetector = new TArchiveDetector("xyz", new
ZipDriver(IOPoolLocator.SINGLETON));

current.setOutputPreferences(current.getOutputPreferences().set(FsOutputOption.GROW));
    current.setArchiveDetector(tArchiveDetector);

    TPath archive = new TPath("test.xyz");
    try {
    TPath entry = new TPath("1.txt");
    Files.copy(entry, archive.resolve(entry));

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
      try {
        TVFS.umount();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

Still the same exception :
de.schlichtherle.truezip.fs.FsReadOnlyArchiveFileSystemException: This is a
read-only archive file system!
at
de.schlichtherle.truezip.fs.FsReadOnlyArchiveFileSystem.mknod(FsReadOnlyArchiveFileSystem.java:54)
at
de.schlichtherle.truezip.fs.FsBasicArchiveController$1Output.mknod(FsBasicArchiveController.java:273)
at
de.schlichtherle.truezip.fs.FsBasicArchiveController$1Output.newOutputStream(FsBasicArchiveController.java:233)
at
de.schlichtherle.truezip.fs.FsContextController$Output.newOutputStream(FsContextController.java:322)
at
de.schlichtherle.truezip.fs.FsResourceController$Output.newOutputStream(FsResourceController.java:280)
at
de.schlichtherle.truezip.socket.DelegatingOutputSocket.newOutputStream(DelegatingOutputSocket.java:57)
at
de.schlichtherle.truezip.fs.FsSyncController$Output.newOutputStream(FsSyncController.java:451)
at
de.schlichtherle.truezip.fs.FsLockController$Output$1NewOutputStream.call(FsLockController.java:509)
at
de.schlichtherle.truezip.fs.FsLockController$Output$1NewOutputStream.call(FsLockController.java:506)
at
de.schlichtherle.truezip.fs.FsLockController.locked(FsLockController.java:328)
at
de.schlichtherle.truezip.fs.FsLockController.writeLocked(FsLockController.java:268)
at
de.schlichtherle.truezip.fs.FsLockController$Output.newOutputStream(FsLockController.java:513)
at
de.schlichtherle.truezip.fs.FsFinalizeController$Output.newOutputStream(FsFinalizeController.java:209)
at
de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController$1Output$NewOutputStream.call(FsFalsePositiveArchiveController.java:409)
at
de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController$1Output$NewOutputStream.call(FsFalsePositiveArchiveController.java:402)
at
de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController$TryChild.call(FsFalsePositiveArchiveController.java:507)
at
de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController.call(FsFalsePositiveArchiveController.java:104)
at
de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController$1Output.newOutputStream(FsFalsePositiveArchiveController.java:399)
at de.schlichtherle.truezip.socket.IOSocket.copy(IOSocket.java:107)
at
de.schlichtherle.truezip.nio.file.TFileSystemProvider.copy(TFileSystemProvider.java:379)
at
de.schlichtherle.truezip.nio.file.TFileSystemProvider.copy(TFileSystemProvider.java:326)
at java.nio.file.Files.copy(Files.java:1219)
at Test.test(Test.java:137)
at Test.main(Test.java:29)



Cheers,
Abhi




On Thu, Jul 4, 2013 at 4:43 PM, Christian Schlichtherle <
christian@...> wrote:

> Hi Abhi,
>
> I finally came round to look into this. Here are my findings:
>
> First, I cannot reproduce your issue: I run your code on Mac OS X, so I
> had to change the input path name from "C:\\test\\1.txt" to "1.txt"
> (using the current directory). With this change, I could successfully write
> "1.txt" and "2.txt" to the archive file.
>
> The exception that you've seen is almost certainly a side effect of
> something else. The Windows file system is a bitch. If you happen to access
> the archive file in any way (even when just listing it in the Windows
> explorer), then the OS may lock it for concurrent writing and this is why
> you get an FsReadOnlyArchiveFileSystemException.
>
> Next, note that there are several layers of file systems in
> TrueZIP/TrueVFS. The FsReadOnlyArchiveFileSystemException is from the
> TrueZIP Kernel. The TFileSystem class does not have direct access to it.
> Hence, TFileSystem.isReadOnly() is just a stub which always returns false,
> even when using a read-only archive driver. Maybe this should get improved,
> but at least it's documented in the Javadocs.
>
> Next, although the code works, it will not use the GROW mode. You have to
> change the following line:
>
>     current.getOutputPreferences().set(FsOutputOption.GROW);
>
> to
>
>
> current.setOutputPreferences(current.getOutputPreferences().set(FsOutputOption.GROW));
>
> Finally, you don't have to use TFileSystem at all. It primarily exists to
> satisfy the contract of the java.nio.file package. In fact, you can
> simplify your code to:
>
>     TConfig current = TConfig.get();
>     TArchiveDetector tArchiveDetector = new TArchiveDetector("xyz", new
> ZipDriver(IOPoolLocator.SINGLETON));
>
> current.setOutputPreferences(current.getOutputPreferences().set(FsOutputOption.GROW));
>     current.setArchiveDetector(tArchiveDetector);
>
>     TPath archive = new TPath("test.xyz");
>     TPath entry = new TPath("2.txt");
>     Files.copy(entry, archive.resolve(entry));
>
> Hope this helps.
>
> Best regards,
> Christian Schlichtherle
>
>
>


[truezip-users] Issue in copying files into existing archive using Path

Abhijeet Desai 07/01/2013

[truezip-users] Re: Issue in copying files into existing archive using Path

Christian Schlichtherle 07/01/2013

[truezip-users] Re: Issue in copying files into existing archive using Path

Abhijeet Desai 07/01/2013

[truezip-users] Re: Issue in copying files into existing archive using Path

Christian Schlichtherle 07/04/2013

[truezip-users] Re: Issue in copying files into existing archive using Path

Abhijeet Desai 07/04/2013

[truezip-users] Re: Issue in copying files into existing archive using Path

Christian Schlichtherle 07/04/2013

[truezip-users] Re: Issue in copying files into existing archive using Path

Abhijeet Desai 07/04/2013

[truezip-users] Re: Issue in copying files into existing archive using Path

Christian Schlichtherle 07/04/2013
 
 
Close
loading
Please Confirm
Close