conor 01/02/03 06:24:43
Modified: src/main/org/apache/tools/tar TarEntry.java
TarInputStream.java
Log:
Add support for untaring of GNU tar files.
Revision Changes Path
1.5 +11 -0 jakarta-ant/src/main/org/apache/tools/tar/TarEntry.java
Index: TarEntry.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/tar/TarEntry.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TarEntry.java 2001/02/01 15:46:31 1.4
+++ TarEntry.java 2001/02/03 14:24:43 1.5
@@ -454,7 +454,18 @@
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.
*
1.3 +12 -0
jakarta-ant/src/main/org/apache/tools/tar/TarInputStream.java
Index: TarInputStream.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/tar/TarInputStream.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TarInputStream.java 2001/01/03 14:18:48 1.2
+++ TarInputStream.java 2001/02/03 14:24:43 1.3
@@ -286,6 +286,18 @@
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;
}