List of usage examples for org.apache.commons.compress.archivers.tar TarArchiveOutputStream LONGFILE_ERROR
int LONGFILE_ERROR
To view the source code for org.apache.commons.compress.archivers.tar TarArchiveOutputStream LONGFILE_ERROR.
Click Source Link
From source file:org.codehaus.plexus.archiver.tar.TarArchiver.java
protected void execute() throws ArchiverException, IOException { if (!checkForced()) { return;// w ww. j a v a 2 s. c o m } ResourceIterator iter = getResources(); if (!iter.hasNext()) { throw new ArchiverException("You must set at least one file."); } File tarFile = getDestFile(); if (tarFile == null) { throw new ArchiverException("You must set the destination tar file."); } if (tarFile.exists() && !tarFile.isFile()) { throw new ArchiverException(tarFile + " isn't a file."); } if (tarFile.exists() && !tarFile.canWrite()) { throw new ArchiverException(tarFile + " is read-only."); } getLogger().info("Building tar: " + tarFile.getAbsolutePath()); final OutputStream os = new FileOutputStream(tarFile); tOut = new TarArchiveOutputStream(compress(compression, os), "UTF8"); if (longFileMode.isTruncateMode()) { tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_TRUNCATE); } else if (longFileMode.isPosixMode() || longFileMode.isPosixWarnMode()) { tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX); // Todo: Patch 2.5.1 for this fix. Also make closeable fix on 2.5.1 tOut.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX); } else if (longFileMode.isFailMode() || longFileMode.isOmitMode()) { tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_ERROR); } else { // warn or GNU tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); } longWarningGiven = false; try { while (iter.hasNext()) { ArchiveEntry entry = iter.next(); // Check if we don't add tar file in itself if (ResourceUtils.isSame(entry.getResource(), tarFile)) { throw new ArchiverException("A tar file cannot include itself."); } String fileName = entry.getName(); String name = StringUtils.replace(fileName, File.separatorChar, '/'); tarFile(entry, tOut, name); } } finally { IOUtil.close(tOut); } }