Hello,
I tried to write the following two files to a TarArchiveOutputStream, I
have the option LONGFILE_POSIX enabled. The two files listed are the
only ones that should be written to the output stream.
/Desktop/Downloads/mplayer-checkout-2012-02-29/tests/ref/cyberia-c93/.svn/text-base/intro1.c93.md5.svn-base
/Desktop/Downloads/mplayer-checkout-2012-02-29/tests/ref/tiertex-seq/.svn/text-base/Gameover.seq.md5.svn-base
Normally, I would expect the archiver to handle file names longer than
100 chars if LONGFILE_POSIX is enabled, but I get the following error
message
java.io.IOException: request to write '117' bytes exceeds size in header
of '0' bytes for entry
'./PaxHeaders.X//Desktop/Downloads/mplayer-checkout-2012-02-29/tests/ref/cyberia-c93/.svn/text-base/'
at
org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.write(TarArchiveOutputStream.java:385)
at java.io.OutputStream.write(OutputStream.java:58)
at
org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.writePaxHeaders(TarArchiveOutputStream.java:485)
at
org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.putArchiveEntry(TarArchiveOutputStream.java:312)
at
target.fileBackupTarget.FileBackupTarget.writeFile(FileBackupTarget.java:209)
at jbackup.JBackup.performBackup(JBackup.java:319)
at jbackup.GUI$1.run(GUI.java:287)
for the first file and a similar one for the second file. If I set the
longfile option to LONGFILE_TRUNCATE the problem does not appear and the
two files are added to the tar archive as expected with truncated file
names.
Here is a code-snippet of the usage of the TarArchiveOutputStream in my
project:
File targetFile;
File source;
long fileLength = source.length();
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
sout = new TarArchiveOutputStream(new FileOutputStream(targetFile));
((TarArchiveOutputStream)
sout).setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
((TarArchiveOutputStream)
sout).setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
((TarArchiveOutputStream) sout).putArchiveEntry(new
TarArchiveEntry(source, source.toString()));
long numberOfPackages = (long) Math.floor(fileLength / (bufferSize));
for (long i = 0; i < numberOfPackages; i++) {
in.read(buffer);
sout.write(buffer);
}
for (long i = numberOfPackages * (bufferSize); i < fileLength; i++) {
sout.write(in.read());
}
((TarArchiveOutputStream) sout).closeArchiveEntry();
Is there any error I made using the tar stream? Thank you for your help.
Best regards
Rico Harnisch
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]