commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1158752 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/dump/ test/java/org/apache/commons/compress/archivers/
Date Wed, 17 Aug 2011 14:49:08 GMT
Author: bodewig
Date: Wed Aug 17 14:49:08 2011
New Revision: 1158752

URL: http://svn.apache.org/viewvc?rev=1158752&view=rev
Log:
make DumpArchiveEntry's getName consistent with other implementations by adding a trailing
/ for directories.  Strip leading . if present.  COMPRESS-132

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java?rev=1158752&r1=1158751&r2=1158752&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
Wed Aug 17 14:49:08 2011
@@ -195,6 +195,7 @@ public class DumpArchiveEntry implements
     // this information is available from standard index.
     private TapeSegmentHeader header = new TapeSegmentHeader();
     private String simpleName;
+    private String originalName;
 
     // this information is available from QFA index
     private int volume;
@@ -217,7 +218,7 @@ public class DumpArchiveEntry implements
      * @param simpleName actual filename.
      */
     public DumpArchiveEntry(String name, String simpleName) {
-        this.name = name;
+        setName(name);
         this.simpleName = simpleName;
     }
 
@@ -561,9 +562,26 @@ public class DumpArchiveEntry implements
     }
 
     /**
+     * Returns the unmodified name of the entry.
+     * @return the name of the entry.
+     */
+    String getOriginalName() {
+        return originalName;
+    }
+
+    /**
      * Sets the name of the entry.
      */
-    public void setName(String name) {
+    public final void setName(String name) {
+        this.originalName = name;
+        if (name != null) {
+            if (".".equals(name) || name.startsWith("./")) {
+                name = name.substring(1);
+            }
+            if (isDirectory() && !name.endsWith("/")) {
+                name += "/";
+            }
+        }
         this.name = name;
     }
 

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java?rev=1158752&r1=1158751&r2=1158752&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
Wed Aug 17 14:49:08 2011
@@ -109,11 +109,11 @@ public class DumpArchiveInputStream exte
         queue = new PriorityQueue<DumpArchiveEntry>(10,
                 new Comparator<DumpArchiveEntry>() {
                     public int compare(DumpArchiveEntry p, DumpArchiveEntry q) {
-                        if ((p.getName() == null) || (q.getName() == null)) {
+                        if ((p.getOriginalName() == null) || (q.getOriginalName() == null))
{
                             return Integer.MAX_VALUE;
                         }
 
-                        return p.getName().compareTo(q.getName());
+                        return p.getOriginalName().compareTo(q.getOriginalName());
                     }
                 });
     }

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java?rev=1158752&r1=1158751&r2=1158752&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/DumpTestCase.java
Wed Aug 17 14:49:08 2011
@@ -104,10 +104,10 @@ public final class DumpTestCase extends 
 
     private void checkDumpArchive(final File f) throws Exception {
         ArrayList<String> expected = new ArrayList<String>();
-        expected.add(".");
-        expected.add("./lost+found");
-        expected.add("./test1.xml");
-        expected.add("./test2.xml");
+        expected.add("/");
+        expected.add("/lost+found/");
+        expected.add("/test1.xml");
+        expected.add("/test2.xml");
         final InputStream is = new FileInputStream(f);
         try {
             checkArchiveContent(new DumpArchiveInputStream(is),



Mime
View raw message