commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1307767 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
Date Sat, 31 Mar 2012 11:19:11 GMT
Author: sebb
Date: Sat Mar 31 11:19:10 2012
New Revision: 1307767

URL: http://svn.apache.org/viewvc?rev=1307767&view=rev
Log:
Use existing utility to simplify code and ensure string conversion uses fixed charset

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=1307767&r1=1307766&r2=1307767&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
Sat Mar 31 11:19:10 2012
@@ -20,12 +20,12 @@ package org.apache.commons.compress.arch
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.ByteBuffer;
 import java.util.Date;
 import java.util.Locale;
 
 import org.apache.commons.compress.archivers.ArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipEncoding;
+import org.apache.commons.compress.utils.ArchiveUtils;
 
 /**
  * This class represents an entry in a Tar archive. It consists
@@ -1043,11 +1043,10 @@ public class TarArchiveEntry implements 
      * @return format type
      */
     private int evaluateType(byte[] header) {
-        final ByteBuffer magic = ByteBuffer.wrap(header, MAGIC_OFFSET, MAGICLEN);
-        if (magic.compareTo(ByteBuffer.wrap(MAGIC_GNU.getBytes())) == 0) {
+        if (ArchiveUtils.matchAsciiBuffer(MAGIC_GNU, header, MAGIC_OFFSET, MAGICLEN)) {
             return FORMAT_OLDGNU;
         }
-        if (magic.compareTo(ByteBuffer.wrap(MAGIC_POSIX.getBytes())) == 0) {
+        if (ArchiveUtils.matchAsciiBuffer(MAGIC_POSIX, header, MAGIC_OFFSET, MAGICLEN)) {
             return FORMAT_POSIX;
         }
         return 0;



Mime
View raw message