ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs UntarTest.java UnzipTest.java
Date Thu, 03 Jul 2003 13:02:01 GMT
bodewig     2003/07/03 06:02:01

  Modified:    .        WHATSNEW
               docs/manual/CoreTasks unzip.html
               src/etc/testcases/taskdefs untar.xml unzip.xml
               src/main/org/apache/tools/ant/taskdefs Expand.java
                        Untar.java
               src/testcases/org/apache/tools/ant/taskdefs UntarTest.java
                        UnzipTest.java
  Log:
  Add support for filename-encodings other than UTF8 to <untar>.
  
  PR: 10504
  
  Revision  Changes    Path
  1.450     +4 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.449
  retrieving revision 1.450
  diff -u -r1.449 -r1.450
  --- WHATSNEW	30 Jun 2003 10:41:00 -0000	1.449
  +++ WHATSNEW	3 Jul 2003 13:02:00 -0000	1.450
  @@ -453,6 +453,10 @@
   * FileUtils#createTempFile will now create temporary files in the 
     directory pointed to by the property java.io.tmpdir
   
  +* <unzip> and friends now supports an optional encoding attribute to
  +  enable it to expand archives created with filenames using an encoding
  +  other than UTF8.  Bugzilla Report 10504.
  +
   Changes from Ant 1.5.2 to Ant 1.5.3
   ===================================
   
  
  
  
  1.12      +18 -4     ant/docs/manual/CoreTasks/unzip.html
  
  Index: unzip.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/unzip.html,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- unzip.html	4 Sep 2002 11:05:16 -0000	1.11
  +++ unzip.html	3 Jul 2003 13:02:01 -0000	1.12
  @@ -46,11 +46,25 @@
     </tr>
     <tr>
       <td valign="top">compression</td>
  -    <td valign="top">compression method for untar.  Allowable values are
  -       &quot;none&quot;, &quot;gzip&quot; and &quot;bzip2&quot;.
 Default is
  -       &quot;none&quot;.</td>
  +    <td valign="top"><b>Note:</b> This attribute is only available for
  +    the <code>untar</code> task.<br>
  +    compression method.  Allowable values are &quot;none&quot;,
  +    &quot;gzip&quot; and &quot;bzip2&quot;.  Default is
  +    &quot;none&quot;.</td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">encoding</td>
  +    <td valign="top"><b>Note:</b> This attribute is not available for
  +    the <code>untar</code> task.<br>
  +    The character encoding that has been used for filenames
  +    inside the zip file.  For a list of possible values see <a
  +    href="http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html">http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html</a>.<br>
  +    Defaults to &quot;UTF8&quot;, use the magic value
  +    <code>native-encoding</code> for the platform's default character
  +    encoding.</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
   
   </table>
   <h3>Examples</h3>
  @@ -89,7 +103,7 @@
   </pre></p>
   </blockquote>
   <hr>
  -<p align="center">Copyright &copy; 2000-2002 Apache Software Foundation. All
rights
  +<p align="center">Copyright &copy; 2000-2003 Apache Software Foundation. All
rights
   Reserved.</p>
   
   </body>
  
  
  
  1.4       +3 -0      ant/src/etc/testcases/taskdefs/untar.xml
  
  Index: untar.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/untar.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- untar.xml	24 Apr 2002 03:09:06 -0000	1.3
  +++ untar.xml	3 Jul 2003 13:02:01 -0000	1.4
  @@ -41,4 +41,7 @@
       <untar src="." dest="." />
     </target>
   
  +  <target name="encoding">
  +    <untar src="expected/asf-logo.gif.tar" dest="." encoding="foo"/>
  +  </target>
   </project>
  
  
  
  1.7       +9 -0      ant/src/etc/testcases/taskdefs/unzip.xml
  
  Index: unzip.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/unzip.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- unzip.xml	23 Jun 2003 14:47:02 -0000	1.6
  +++ unzip.xml	3 Jul 2003 13:02:01 -0000	1.7
  @@ -78,4 +78,13 @@
       </unzip>
     </target>
   
  +  <!-- Bugzilla Report 10504 -->
  +  <target name="encodingTest">
  +    <mkdir dir="unziptestin"/>
  +    <touch file="unziptestin/foo"/>
  +    <zip zipfile="unziptest.zip" basedir="unziptestin" encoding="UTF16"/>
  +    <mkdir dir="unziptestout"/>
  +    <unzip src="unziptest.zip" dest="unziptestout" encoding="UTF16"/>
  +  </target>
  +
   </project>
  
  
  
  1.45      +20 -4     ant/src/main/org/apache/tools/ant/taskdefs/Expand.java
  
  Index: Expand.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Expand.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Expand.java	3 Jul 2003 08:30:11 -0000	1.44
  +++ Expand.java	3 Jul 2003 13:02:01 -0000	1.45
  @@ -95,9 +95,10 @@
       private boolean overwrite = true;
       private Vector patternsets = new Vector();
       private Vector filesets = new Vector();
  -    private static final byte[] ZIPMARKER = {0x50, 0x4b, 0x03, 0x04};
  -    private static final int MARKER_SIZE = ZIPMARKER.length;
  -    private static final int MAX_LOOKAHEAD = 50 * 1024; // 50K.
  +
  +    private static final String NATIVE_ENCODING = "native-encoding";
  +
  +    private String encoding = "UTF8";
   
       /**
        * Do the work.
  @@ -155,7 +156,7 @@
           log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
           ZipFile zf = null;
           try {
  -            zf = new ZipFile(srcF, "UTF8");
  +            zf = new ZipFile(srcF, encoding);
               Enumeration enum = zf.getEntries();
               while (enum.hasMoreElements()) {
                   ZipEntry ze = (ZipEntry) enum.nextElement();
  @@ -322,6 +323,21 @@
        */
       public void addFileset(FileSet set) {
           filesets.addElement(set);
  +    }
  +
  +    /**
  +     * Sets the encoding to assume for file names and comments.
  +     *
  +     * <p>Set to <code>native-encoding</code> if you want your
  +     * platform's native encoding, defaults to UTF8.</p>
  +     *
  +     * @since Ant 1.6
  +     */
  +    public void setEncoding(String encoding) {
  +        if (NATIVE_ENCODING.equals(encoding)) {
  +            encoding = null;
  +        }
  +        this.encoding = encoding;
       }
   
   }
  
  
  
  1.33      +12 -1     ant/src/main/org/apache/tools/ant/taskdefs/Untar.java
  
  Index: Untar.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Untar.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- Untar.java	7 Mar 2003 11:23:02 -0000	1.32
  +++ Untar.java	3 Jul 2003 13:02:01 -0000	1.33
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -110,6 +110,17 @@
        */
       public void setCompression(UntarCompressionMethod method) {
           compression = method;
  +    }
  +
  +    /**
  +     * No encoding support in Untar.
  +     *
  +     * @since Ant 1.6
  +     */
  +    public void setEncoding(String encoding) {
  +        throw new BuildException("The " + getTaskName() 
  +                                 + " task doesn't support the encoding"
  +                                 + " attribute", getLocation());
       }
   
       protected void expandFile(FileUtils fileUtils, File srcF, File dir) {
  
  
  
  1.6       +11 -5     ant/src/testcases/org/apache/tools/ant/taskdefs/UntarTest.java
  
  Index: UntarTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/UntarTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UntarTest.java	7 Mar 2003 11:23:11 -0000	1.5
  +++ UntarTest.java	3 Jul 2003 13:02:01 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -53,7 +53,6 @@
    */
   package org.apache.tools.ant.taskdefs;
   
  -import java.io.File;
   import org.apache.tools.ant.BuildFileTest;
   import org.apache.tools.ant.util.FileUtils;
   
  @@ -117,8 +116,15 @@
                                              project.resolveFile("asf-logo.gif")));
       }
   
  -    public void testSrcDirTest() throws java.io.IOException {
  -        FileUtils fileUtils = FileUtils.newFileUtils();
  +    public void testSrcDirTest() {
           expectBuildException("srcDirTest", "Src cannot be a directory.");
       }
  +
  +    public void testEncoding() {
  +        expectSpecificBuildException("encoding", 
  +                                     "<untar> overrides setEncoding.",
  +                                     "The untar task doesn't support the "
  +                                     + "encoding attribute");
  +    }
  +
   }
  
  
  
  1.12      +9 -0      ant/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java
  
  Index: UnzipTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- UnzipTest.java	3 Jul 2003 08:30:11 -0000	1.11
  +++ UnzipTest.java	3 Jul 2003 13:02:01 -0000	1.12
  @@ -153,4 +153,13 @@
                      getProject().resolveFile("unziptestout/2/bar").exists());
       }
   
  +    /*
  +     * PR 10504
  +     */
  +    public void testEncoding() {
  +        executeTarget("encodingTest");
  +        assertTrue("foo has been properly named",
  +                   getProject().resolveFile("unziptestout/foo").exists());
  +    }
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message