@@ -274,12 +274,12 @@ public class TarOutputStream extends FilterOutputStream {
Map<String, String> paxHeaders = new HashMap<String, String>();
Map<String, String> paxHeaders = new HashMap<String, String>();
final String entryName = entry.getName();
final String entryName = entry.getName();
boolean paxHeaderContainsPath = handleLongName(entryName, paxHeaders, "path",
boolean paxHeaderContainsPath = handleLongName(entryName, paxHeaders, "path",
TarConstants.LF_GNUTYPE_LONGNAME);
TarConstants.LF_GNUTYPE_LONGNAME, "file name" );
final String linkName = entry.getLinkName();
final String linkName = entry.getLinkName();
boolean paxHeaderContainsLinkPath = linkName != null
boolean paxHeaderContainsLinkPath = linkName != null
&& handleLongName(linkName, paxHeaders, "linkpath",
&& handleLongName(linkName, paxHeaders, "linkpath",
TarConstants.LF_GNUTYPE_LONGLINK);
TarConstants.LF_GNUTYPE_LONGLINK, "link name" );
if (bigNumberMode == BIGNUMBER_POSIX) {
if (bigNumberMode == BIGNUMBER_POSIX) {
addPaxHeadersForBigNumbers(paxHeaders, entry);
addPaxHeadersForBigNumbers(paxHeaders, entry);
@@ -589,18 +589,20 @@ public class TarOutputStream extends FilterOutputStream {
* paxHeaderName parameter if longFileMode is POSIX</li>
* paxHeaderName parameter if longFileMode is POSIX</li>
* <li>it creates a GNU longlink entry who's type is given by
* <li>it creates a GNU longlink entry who's type is given by
* the linkType parameter if longFileMode is GNU</li>
* the linkType parameter if longFileMode is GNU</li>
* <li>throws an exception othewise.</li>
* <li>it throws an exception if longFileMode is ERROR</li>
* <li>it truncates the name if longFileMode is TRUNCATE</li>
* </ul></p>
* </ul></p>
*
*
* @param name the name to write
* @param name the name to write
* @param paxHeaders current map of pax headers
* @param paxHeaders current map of pax headers
* @param paxHeaderName name of the pax header to write
* @param paxHeaderName name of the pax header to write
* @param linkType type of the GNU entry to write
* @param linkType type of the GNU entry to write
* @param fieldName the name of the field
* @return whether a pax header has been written.
* @return whether a pax header has been written.
*/
*/
private boolean handleLongName(String name,
private boolean handleLongName(String name,
Map<String, String> paxHeaders,
Map<String, String> paxHeaders,
String paxHeaderName, byte linkType)
String paxHeaderName, byte linkType, String fieldName )
throws IOException {
throws IOException {
final ByteBuffer encodedName = encoding.encode(name);
final ByteBuffer encodedName = encoding.encode(name);
final int len = encodedName.limit() - encodedName.position();
final int len = encodedName.limit() - encodedName.position();
@@ -621,7 +623,7 @@ public class TarOutputStream extends FilterOutputStream {
write(0); // NUL terminator
write(0); // NUL terminator
closeEntry();
closeEntry();
} else if (longFileMode != LONGFILE_TRUNCATE) {
} else if (longFileMode != LONGFILE_TRUNCATE) {
throw new RuntimeException(paxHeader Name + " '" + name
throw new RuntimeException(field Name + " '" + name
+ "' is too long ( > "
+ "' is too long ( > "
+ TarConstants.NAMELEN + " bytes)");
+ TarConstants.NAMELEN + " bytes)");
}
}