You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2002/09/03 18:37:58 UTC

DO NOT REPLY [Bug 12267] New: - Add ability to unzip into separate folders

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12267>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12267

Add ability to unzip into separate folders

           Summary: Add ability to unzip into separate folders
           Product: Ant
           Version: 1.5
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Core tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: adam.mlodzinski@sitraka.com


This is a request for the ant unzip task to be able to unzip a <fileset> of zip
files to newly created folders based on the zip file name. In other words,
giving the unzip task a number of zip files, rather than expand them into the
folder specified by the dest attribute, use the base name of the zip file as the
name of a new subfolder created in dest, then expand the contents of the zip
file into that subfolder.
For example, the following unzip task
<unzip dest="extracts" separate="true">
	<fileset dir="${zipFolder}" >
	  <include name="*.zip" >
	</fileset>
</unzip>, 
where zipFolder contains buildA.zip and buildB.zip, would expand buildA.zip to
extracts/buildA and buildB.zip to extracts/buildB.
The following additional code inserted at the beginning of 
org.apache.tools.ant.taskdefs.Expand.expandFile(FileUtils, File, File)
implements this ability:
protected void expandFile(FileUtils fileUtils, File srcF, File destDir) {
    File dir = destDir;
    if (separate) {
        String fileNameBase = srcF.getName();
        fileNameBase = fileNameBase.substring(0, fileNameBase.indexOf('.'));
        dir = new File(destDir,fileNameBase);
        dir.mkdir();
    }
    log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
    ZipInputStream zis = null;
    [continues unchanged]

I don't think this accounts for zip files in subdirectories - which would
probably need to have the relative path recreated to avoid filename conflicts. 

Mundane info:
separate is defined as
    private boolean separate = false;  // false default maintains previous
behaviour when not used.

and the attribute is made available by
    /**
     * Should files in filesets or src be extracted to new subdirectories
     * of the same name?
     */
    public void setSeparate(boolean b){
        separate = b;
    }

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>