geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r428834 - in /geronimo/sandbox/svkmerge/m2migration/modules/common/src: ./ java/org/apache/geronimo/common/FileUtils.java
Date Fri, 04 Aug 2006 18:35:09 GMT
Author: jdillon
Date: Fri Aug  4 11:35:09 2006
New Revision: 428834

URL: http://svn.apache.org/viewvc?rev=428834&view=rev
Log:
 r627@jason-dillons-computer (orig r427996):  jdillon | 2006-08-02 07:14:45 -0700
  r612@dyn456093 (orig r427669):  ammulder | 2006-08-01 11:16:31 -0700
  Merge fix for GERONIMO-2228 (and plumbing for GERONIMO-1869) to trunk.
  
 

Added:
    geronimo/sandbox/svkmerge/m2migration/modules/common/src/java/org/apache/geronimo/common/FileUtils.java
  (with props)
Modified:
    geronimo/sandbox/svkmerge/m2migration/modules/common/src/   (props changed)

Propchange: geronimo/sandbox/svkmerge/m2migration/modules/common/src/
------------------------------------------------------------------------------
--- svk:merge (added)
+++ svk:merge Fri Aug  4 11:35:09 2006
@@ -0,0 +1 @@
+13f79535-47bb-0310-9956-ffa450edef68:/geronimo/sandbox/svkmerge/trunk/modules/common/src:427996

Added: geronimo/sandbox/svkmerge/m2migration/modules/common/src/java/org/apache/geronimo/common/FileUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/svkmerge/m2migration/modules/common/src/java/org/apache/geronimo/common/FileUtils.java?rev=428834&view=auto
==============================================================================
--- geronimo/sandbox/svkmerge/m2migration/modules/common/src/java/org/apache/geronimo/common/FileUtils.java
(added)
+++ geronimo/sandbox/svkmerge/m2migration/modules/common/src/java/org/apache/geronimo/common/FileUtils.java
Fri Aug  4 11:35:09 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.common;
+
+import java.io.File;
+import java.io.DataInputStream;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.zip.ZipFile;
+
+/**
+ * Utility functions related to Files.
+ *
+ * @version $Rev: 368994 $ $Date: 2006-01-14 02:07:18 -0500 (Sat, 14 Jan 2006) $
+ */
+public class FileUtils {
+    /**
+     * Determine whether a file is a JAR File.
+     */
+    public static boolean isJarFile(File file) throws IOException {
+        if(!isZipFile(file)) {
+            return false;
+        }
+        ZipFile zip = new ZipFile(file);
+        boolean manifest = zip.getEntry("META-INF/MANIFEST.MF") != null;
+        zip.close();
+        return manifest;
+    }
+
+    /**
+     * Determine whether a file is a ZIP File.
+     */
+    public static boolean isZipFile(File file) throws IOException {
+        if(file.isDirectory()) {
+            return false;
+        }
+        if(!file.canRead()) {
+            throw new IOException("Cannot read file "+file.getAbsolutePath());
+        }
+        if(file.length() < 4) {
+            return false;
+        }
+        DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
+        int test = in.readInt();
+        in.close();
+        return test == 0x504b0304;
+    }
+
+}

Propchange: geronimo/sandbox/svkmerge/m2migration/modules/common/src/java/org/apache/geronimo/common/FileUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message