I want to use the TrueZip library to append a file to an existing archive (not by unpacking, adding a file and repacking - the new versions are supposed to have this feature), but I find it a bit difficult to understand the API. Can please someone, more knowledgeable than me, suggest how to do this in a few lines?
Asked
Active
Viewed 2,100 times
1 Answers
2
Google is your friend:
class MyApplication extends TApplication {
@Override
protected void setup() {
// This should obtain the global configuration.
TConfig config = TConfig.get();
// Set FsOutputOption.GROW for appending-to rather than reassembling an
// archive file.
config.setOutputPreferences(
config.getOutputPreferences.set(FsOutputOption.GROW));
}
...
}

Chris White
- 29,949
- 4
- 71
- 93
-
1thank you, I have seen this reference.. it is precisely the pain of understanding what goes on that I try to avoid.. I need just: handle=open("my.zip"); add(bytes,handle); close(handle) - it really, really should not be more complicated than this.. and if it is, I'd rather use a system call.. – John Donn Mar 27 '12 at 15:14
-
1So you want to write an abstraction layer? Shouldn't be too difficult to take this article and wrap it – Chris White Mar 27 '12 at 15:33
-
2I don't get the problem. Why don't you just copy-paste the second example from the blog article and add your code for output? You can easily wrap the example in your own method, too?! – Christian Schlichtherle Mar 28 '12 at 12:55
-
2To Christian Schlichtherle: I do appreciate the efforts you (and others?) have put into TrueZip. But it is not only me who is not comfortable with the API. These seem not to follow the principle "simple things should be simple, and difficult things possible" (of course TrueZip here is in a good company). Or maybe there is a problem with the documentation. But it seems also that TrueZip does fill a lacune in Java, and for this - my respect. – John Donn Mar 29 '12 at 13:27
-
Well, if you carefully look at the second sample again, then you'll sure note that it works almost exactly as you proposed in the first comment to this answer. There is only some overhead to instruct TrueZIP to use the appending rather than updating strategy. – Christian Schlichtherle Mar 29 '12 at 17:15
-
Link-only answers should be avoided, because – like in this case – they can become dead, rendering the answer useless – phil294 Jul 21 '20 at 14:01
-
@phil294 - i'll update with a new link (which took all of two seconds to find, again google it your friend) and add in a snippet to appease. – Chris White Jul 21 '20 at 18:35