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 2009/08/01 17:04:23 UTC
svn commit: r799882 - in
/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers:
ar/ArArchiveEntry.java ar/ArArchiveInputStream.java
cpio/CpioArchiveOutputStream.java
Author: bodewig
Date: Sat Aug 1 15:04:22 2009
New Revision: 799882
URL: http://svn.apache.org/viewvc?rev=799882&view=rev
Log:
now ar and cpio really use seconds internally and read/write them as such.
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java?rev=799882&r1=799881&r2=799882&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java Sat Aug 1 15:04:22 2009
@@ -70,11 +70,32 @@
private final long lastModified;
private final long length;
+ /**
+ * Create a new instance using a couple of default values.
+ *
+ * <p>Sets userId and groupId to 0, the octal file mode to 644 and
+ * the last modified time to the current time.</p>
+ *
+ * @param name name of the entry
+ * @param length length of the entry in bytes
+ */
public ArArchiveEntry(String name, long length) {
- this(name, length, 0, 0, DEFAULT_MODE, System.currentTimeMillis());
+ this(name, length, 0, 0, DEFAULT_MODE,
+ System.currentTimeMillis() / 1000);
}
- public ArArchiveEntry(String name, long length, int userId, int groupId, int mode, long lastModified) {
+ /**
+ * Create a new instance.
+ *
+ * @param name name of the entry
+ * @param length length of the entry in bytes
+ * @param userId numeric user id
+ * @param groupId numeric group id
+ * @param mode file mode
+ * @param lastModified last modified time in seconds since the epoch
+ */
+ public ArArchiveEntry(String name, long length, int userId, int groupId,
+ int mode, long lastModified) {
this.name = name;
this.length = length;
this.userId = userId;
@@ -83,9 +104,13 @@
this.lastModified = lastModified;
}
+ /**
+ * Create a new instance using the attributes of the given file
+ */
public ArArchiveEntry(File inputFile, String entryName) {
// TODO sort out mode
- this(entryName, inputFile.isFile() ? inputFile.length() : 0, 0, 0, 0, inputFile.lastModified());
+ this(entryName, inputFile.isFile() ? inputFile.length() : 0,
+ 0, 0, 0, inputFile.lastModified() / 1000);
}
public long getSize() {
@@ -108,6 +133,9 @@
return mode;
}
+ /**
+ * Last modified time in seconds since the epoch.
+ */
public long getLastModified() {
return lastModified;
}
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=799882&r1=799881&r2=799882&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Sat Aug 1 15:04:22 2009
@@ -142,10 +142,20 @@
if (temp.endsWith("/")) {
temp = temp.substring(0, temp.length() - 1);
}
- currentEntry = new ArArchiveEntry(temp, Long.parseLong(new String(length).trim()));
+ currentEntry = new ArArchiveEntry(temp, asLong(length), asInt(userid),
+ asInt(groupid), asInt(filemode),
+ asLong(lastmodified));
return currentEntry;
}
+ private long asLong(byte[] input) {
+ return Long.parseLong(new String(input).trim());
+ }
+
+ private int asInt(byte[] input) {
+ return Integer.parseInt(new String(input).trim());
+ }
+
/*
* (non-Javadoc)
*
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=799882&r1=799881&r2=799882&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Sat Aug 1 15:04:22 2009
@@ -153,7 +153,7 @@
closeArchiveEntry(); // close previous entry
}
if (e.getTime() == -1) {
- e.setTime(System.currentTimeMillis());
+ e.setTime(System.currentTimeMillis() / 1000);
}
final short format = e.getFormat();