Author: sebb
Date: Thu Mar 26 20:27:25 2009
New Revision: 758837

URL: http://svn.apache.org/viewvc?rev=758837&view=rev
Log:
The default value for fileFormat must be chosen so checkNewFormat() and 
checkOldFormat() both fail; -1 is not suitable.
Initialise other fields to zero as that is what the trailer needs.
Update Javadoc

Modified:
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java?rev=758837&r1=758836&r2=758837&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
 Thu Mar 26 20:27:25 2009
@@ -132,28 +132,33 @@
  */
 public class CpioArchiveEntry implements CpioConstants, ArchiveEntry {
 
-    private long chksum = 0;
-
+    // Header description fields - should be same throughout an archive
+    
     /**
      * See {...@link CpioArchiveEntry#setFormat(short)} for possible values.
      */
-   private short fileFormat = -1;
+    private short fileFormat = 0; // Default chosen so checkNewFormat() and 
checkOldFormat() both fail 
+
+    /** The number of bytes in each header record; depends on the file format 
*/
+    private long headerSize = -1;
+
+    // Header fields
+    
+    private long chksum = 0;
 
     private long filesize = 0;
 
     private long gid = 0;
 
-    private long headerSize = -1;
-
     private long inode = 0;
 
     private long maj = 0;
 
     private long min = 0;
 
-    private long mode = -1;
+    private long mode = 0;
 
-    private long mtime = -1;
+    private long mtime = 0;
 
     private String name;
 
@@ -188,7 +193,7 @@
     }
 
     /**
-     * Ceates a CPIOArchiveEntry with a specified name. The format of this 
entry
+     * Creates a CPIOArchiveEntry with a specified name. The format of this 
entry
      * will be the new format.
      * 
      * @param name
@@ -535,12 +540,14 @@
     }
 
     /**
-     * Set the format for this entry. Possible values are:
+     * Set the header format for this entry.
+     * <br/>
+     * Possible values are:
      * <p>
-     * {...@link CPIOConstants.FORMAT_NEW}<br/>
-     * {...@link CPIOConstants.FORMAT_NEW_CRC}<br/>
-     * {...@link CPIOConstants.FORMAT_OLD_BINARY}<br/>
-     * {...@link CPIOConstants.FORMAT_OLD_ASCII}<br/>
+     * {...@link CpioConstants.FORMAT_NEW}<br/>
+     * {...@link CpioConstants.FORMAT_NEW_CRC}<br/>
+     * {...@link CpioConstants.FORMAT_OLD_BINARY}<br/>
+     * {...@link CpioConstants.FORMAT_OLD_ASCII}<br/>
      * 
      * @param format
      *            The format to set.
@@ -548,24 +555,21 @@
     final void setFormat(final short format) {
         switch (format) {
         case FORMAT_NEW:
-            this.fileFormat = FORMAT_NEW;
             this.headerSize = 110;
             break;
         case FORMAT_NEW_CRC:
-            this.fileFormat = FORMAT_NEW_CRC;
             this.headerSize = 110;
             break;
         case FORMAT_OLD_ASCII:
-            this.fileFormat = FORMAT_OLD_ASCII;
             this.headerSize = 76;
             break;
         case FORMAT_OLD_BINARY:
-            this.fileFormat = FORMAT_OLD_BINARY;
             this.headerSize = 26;
             break;
         default:
             throw new IllegalArgumentException("Unknown header type");
         }
+        this.fileFormat = format;
     }
 
     /**


Reply via email to