java - Problems writting in archive using TrueZip and symbolic links -
i use truezip (v 7.6.4) write zip archive. have set of folders this:
> ls -l /home/remi drwxr-xr-x 2 remi remi 4096 sept. 10 16:49 testtz drwxr-xr-x 2 remi remi 4096 sept. 10 16:49 symlinktarget lrwxrwxrwx 1 remi remi 14 sept. 10 16:47 symlink -> symlinktarget/ > ls -l /home/remi/testtz lrwxrwxrwx 1 remi remi 25 sept. 10 16:47 symlink -> /home/remi/symlinktarget/
here code:
package com.tests.forstackoverflow.truezip; import java.io.file; import java.io.writer; import org.slf4j.logger; import org.slf4j.loggerfactory; import de.schlichtherle.truezip.file.tfile; import de.schlichtherle.truezip.file.tfilewriter; import de.schlichtherle.truezip.file.tvfs; import de.schlichtherle.truezip.fs.fssyncexception; public class testtz { logger logger = loggerfactory.getlogger(getclass()); public void writeinarchive(string archivename) { final file f = new tfile(new file(archivename) + "/hello.txt"); try (writer writer = new tfilewriter(f)) { writer.write("hello world!\n"); } catch(exception e) { logger.error("exception raised:", e); } try { tvfs.umount(); } catch(fssyncexception e) { logger.error("umount error", e); } } public static void main(string args[]) { testtz test = new testtz(); test.writeinarchive("/home/remi/testtz/hello.zip"); test.writeinarchive("/home/remi/symlink/hello.zip"); test.writeinarchive("/home/remi/testtz/symlink/hello2.zip"); } }
first call writeinarchive
works fine. subsequent calls (which gives archive path last directory symbolic link) raise following exception:
sept. 10, 2014 4:49:55 pm com.tests.forstackoverflow.truezip.testtz writeinarchive grave: exception raised: java.io.filenotfoundexception: /home/remi/symlink/hello.zip/hello.txt @ de.schlichtherle.truezip.file.tfileoutputstream.newoutputstream(tfileoutputstream.java:147) @ de.schlichtherle.truezip.file.tfileoutputstream.<init>(tfileoutputstream.java:116) @ de.schlichtherle.truezip.file.tfilewriter.<init>(tfilewriter.java:42) @ com.tests.forstackoverflow.truezip.testtz.writeinarchive(testtz.java:21) @ com.tests.forstackoverflow.truezip.testtz.main(testtz.java:38) caused by: java.nio.file.filealreadyexistsexception: /home/remi/symlink @ sun.nio.fs.unixexception.translatetoioexception(unixexception.java:88) @ sun.nio.fs.unixexception.rethrowasioexception(unixexception.java:102) @ sun.nio.fs.unixexception.rethrowasioexception(unixexception.java:107) @ sun.nio.fs.unixfilesystemprovider.createdirectory(unixfilesystemprovider.java:383) @ java.nio.file.files.createdirectory(files.java:628) @ java.nio.file.files.createandcheckisdirectory(files.java:732) @ java.nio.file.files.createdirectories(files.java:681) @ de.schlichtherle.truezip.fs.nio.file.fileoutputsocket.begin(fileoutputsocket.java:97) @ de.schlichtherle.truezip.fs.nio.file.fileoutputsocket.newoutputstream(fileoutputsocket.java:211) @ de.schlichtherle.truezip.fs.archive.zip.optionoutputsocket.newoutputstream(optionoutputsocket.java:48) @ de.schlichtherle.truezip.fs.archive.zip.zipdriver.newoutputshop(zipdriver.java:589) @ de.schlichtherle.truezip.fs.archive.zip.zipdriver.newoutputshop0(zipdriver.java:579) @ de.schlichtherle.truezip.fs.archive.zip.zipdriver.newoutputshop(zipdriver.java:564) @ de.schlichtherle.truezip.fs.fstargetarchivecontroller.makeoutputarchive(fstargetarchivecontroller.java:247) @ de.schlichtherle.truezip.fs.fstargetarchivecontroller.mount0(fstargetarchivecontroller.java:182) @ de.schlichtherle.truezip.fs.fstargetarchivecontroller.mount(fstargetarchivecontroller.java:155) @ de.schlichtherle.truezip.fs.fsfilesystemarchivecontroller$resetfilesystem.automount(fsfilesystemarchivecontroller.java:85) @ de.schlichtherle.truezip.fs.fsfilesystemarchivecontroller.automount(fsfilesystemarchivecontroller.java:37) @ de.schlichtherle.truezip.fs.fsbasicarchivecontroller$1output.mknod(fsbasicarchivecontroller.java:273) @ de.schlichtherle.truezip.fs.fsbasicarchivecontroller$1output.newoutputstream(fsbasicarchivecontroller.java:233) @ de.schlichtherle.truezip.fs.fscontextcontroller$output.newoutputstream(fscontextcontroller.java:322) @ de.schlichtherle.truezip.fs.fsresourcecontroller$output.newoutputstream(fsresourcecontroller.java:273) @ de.schlichtherle.truezip.socket.delegatingoutputsocket.newoutputstream(delegatingoutputsocket.java:57) @ de.schlichtherle.truezip.fs.fssynccontroller$output.newoutputstream(fssynccontroller.java:432) @ de.schlichtherle.truezip.fs.fslockcontroller$output$1newoutputstream.call(fslockcontroller.java:509) @ de.schlichtherle.truezip.fs.fslockcontroller$output$1newoutputstream.call(fslockcontroller.java:506) @ de.schlichtherle.truezip.fs.fslockcontroller.locked(fslockcontroller.java:328) @ de.schlichtherle.truezip.fs.fslockcontroller.writelocked(fslockcontroller.java:268) @ de.schlichtherle.truezip.fs.fslockcontroller$output.newoutputstream(fslockcontroller.java:513) @ de.schlichtherle.truezip.fs.fsfinalizecontroller$output.newoutputstream(fsfinalizecontroller.java:209) @ de.schlichtherle.truezip.fs.fsfalsepositivearchivecontroller$1output$newoutputstream.call(fsfalsepositivearchivecontroller.java:409) @ de.schlichtherle.truezip.fs.fsfalsepositivearchivecontroller$1output$newoutputstream.call(fsfalsepositivearchivecontroller.java:402) @ de.schlichtherle.truezip.fs.fsfalsepositivearchivecontroller$trychild.call(fsfalsepositivearchivecontroller.java:507) @ de.schlichtherle.truezip.fs.fsfalsepositivearchivecontroller.call(fsfalsepositivearchivecontroller.java:104) @ de.schlichtherle.truezip.fs.fsfalsepositivearchivecontroller$1output.newoutputstream(fsfalsepositivearchivecontroller.java:399) @ de.schlichtherle.truezip.file.tfileoutputstream.newoutputstream(tfileoutputstream.java:143) ... 4 more
are adding truezip existing project? if so, need include truezip-driver-zip dependency in project. the maven repo here. don't need import project, need dependency jar built project. if aren't using maven, use whichever build process have include it.
Comments
Post a Comment