Browse Source

Add support for untaring of GNU tar files.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268568 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
63664a8786
2 changed files with 23 additions and 0 deletions
  1. +11
    -0
      src/main/org/apache/tools/tar/TarEntry.java
  2. +12
    -0
      src/main/org/apache/tools/tar/TarInputStream.java

+ 11
- 0
src/main/org/apache/tools/tar/TarEntry.java View File

@@ -454,7 +454,18 @@ public class TarEntry implements TarConstants {
public void setSize(long size) {
this.size = size;
}

/**
* Indicate if this entry is a GNU long name block
*
* @return true if this is a long name extension provided by GNU tar
*/
public boolean isGNULongNameEntry() {
return linkFlag == LF_GNUTYPE_LONGNAME &&
name.toString().equals(GNU_LONGLINK);
}

/**
* Return whether or not this entry represents a directory.
*


+ 12
- 0
src/main/org/apache/tools/tar/TarInputStream.java View File

@@ -286,6 +286,18 @@ public class TarInputStream extends FilterInputStream {
this.entrySize = (int) this.currEntry.getSize();
}

if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) {
// read in the name
StringBuffer longName = new StringBuffer();
byte[] buffer = new byte[256];
int length = 0;
while ((length = read(buffer)) >= 0) {
longName.append(new String(buffer, 0, length));
}
getNextEntry();
this.currEntry.setName(longName.toString());
}

return this.currEntry;
}



Loading…
Cancel
Save