harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhouke...@apache.org
Subject svn commit: r787949 - /harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
Date Wed, 24 Jun 2009 08:58:48 GMT
Author: zhoukevin
Date: Wed Jun 24 08:58:48 2009
New Revision: 787949

URL: http://svn.apache.org/viewvc?rev=787949&view=rev
Log:
Applied the patch for HARMONY-6243, JRE should remind user to specify "--no-gzip" cmd line
option if he packs a jar into a file with name which doesn't ends with ".gz".

Modified:
    harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java

Modified: harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java?rev=787949&r1=787948&r2=787949&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
Wed Jun 24 08:58:48 2009
@@ -119,16 +119,36 @@
                 break;
             }
         }
-        if(inputFileName == null || outputFileName == null) {
+
+        pack(inputFileName, outputFileName, options);
+    }
+
+    private static void pack(String inputFileName, String outputFileName,
+            PackingOptions options) throws Exception {
+        if (inputFileName == null || outputFileName == null) {
+            printUsage();
+            return;
+        }
+
+        if (options.isGzip() && !outputFileName.endsWith(".gz")) {
+            printErrorMessage("To write a *.pack file, specify --no-gzip: "
+                    + outputFileName);
             printUsage();
             return;
         }
-        JarInputStream inputStream = new JarInputStream(new FileInputStream(inputFileName));
-        OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFileName));
+
+        JarInputStream inputStream = new JarInputStream(new FileInputStream(
+                inputFileName));
+        OutputStream outputStream = new BufferedOutputStream(
+                new FileOutputStream(outputFileName));
         Archive archive = new Archive(inputStream, outputStream, options);
         archive.pack();
     }
 
+    private static void printErrorMessage(String mesg) {
+        System.out.println("Error: " + mesg);
+    }
+
     private static void printUsage() {
         System.out.println("Usage:  pack200 [-opt... | --option=value]... x.pack[.gz] y.jar");
         System.out.println("(For more information, run pack200 --help)");



Mime
View raw message