You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2012/03/04 08:46:49 UTC
svn commit: r1296764 - in /commons/proper/compress/trunk/src:
main/java/org/apache/commons/compress/archivers/tar/
test/java/org/apache/commons/compress/archivers/tar/ test/resources/
Author: bodewig
Date: Sun Mar 4 07:46:48 2012
New Revision: 1296764
URL: http://svn.apache.org/viewvc?rev=1296764&view=rev
Log:
parse last modification date from PAX headers if present. COMPRESS-182
Added:
commons/proper/compress/trunk/src/test/resources/preepoch-posix.tar (with props)
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1296764&r1=1296763&r2=1296764&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Sun Mar 4 07:46:48 2012
@@ -339,12 +339,14 @@ public class TarArchiveInputStream exten
private void applyPaxHeadersToCurrentEntry(Map<String, String> headers) {
/*
* The following headers are defined for Pax.
- * atime, ctime, mtime, charset: cannot use these without changing TarArchiveEntry fields
+ * atime, ctime, charset: cannot use these without changing TarArchiveEntry fields
+ * mtime
* comment
* gid, gname
* linkpath
* size
* uid,uname
+ * SCHILY.devminor, SCHILY.devmajor: don't have setters/getters for those
*/
for (Entry<String, String> ent : headers.entrySet()){
String key = ent.getKey();
@@ -363,6 +365,14 @@ public class TarArchiveInputStream exten
currEntry.setUserName(val);
} else if ("size".equals(key)){
currEntry.setSize(Long.parseLong(val));
+ } else if ("mtime".equals(key)){
+ currEntry.setModTime((long) (Double.parseDouble(val) * 1000));
+ /* currently not settable
+ } else if ("SCHILY.devminor".equals(key)){
+ currEntry.setMinor(Integer.parseInt(val));
+ } else if ("SCHILY.devmajor".equals(key)){
+ currEntry.setMajor(Integer.parseInt(val));
+ */
}
}
}
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java?rev=1296764&r1=1296763&r2=1296764&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java Sun Mar 4 07:46:48 2012
@@ -69,7 +69,17 @@ public class TarArchiveInputStreamTest {
@Test
public void datePriorToEpochInGNUFormat() throws Exception {
- URL tar = getClass().getResource("/preepoch-gnu.tar");
+ datePriorToEpoch("/preepoch-gnu.tar");
+ }
+
+
+ @Test
+ public void datePriorToEpochInPAXFormat() throws Exception {
+ datePriorToEpoch("/preepoch-posix.tar");
+ }
+
+ private void datePriorToEpoch(String archive) throws Exception {
+ URL tar = getClass().getResource(archive);
TarArchiveInputStream in = null;
try {
in = new TarArchiveInputStream(new FileInputStream(new File(new URI(tar.toString()))));
Added: commons/proper/compress/trunk/src/test/resources/preepoch-posix.tar
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/preepoch-posix.tar?rev=1296764&view=auto
==============================================================================
Binary file - no diff available.
Propchange: commons/proper/compress/trunk/src/test/resources/preepoch-posix.tar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream