git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271404 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -111,7 +111,7 @@ public class Zip | |||||
| /** | /** | ||||
| * Sets whether we want to compress the files or only store them. | * Sets whether we want to compress the files or only store them. | ||||
| * | * | ||||
| * @param c The new Compress value | |||||
| * @param compress The new Compress value | |||||
| */ | */ | ||||
| public void setCompress( final boolean compress ) | public void setCompress( final boolean compress ) | ||||
| { | { | ||||
| @@ -146,8 +146,6 @@ public class Zip | |||||
| /** | /** | ||||
| * Emulate Sun's jar utility by not adding parent dirs | * Emulate Sun's jar utility by not adding parent dirs | ||||
| * | |||||
| * @param f The new Filesonly value | |||||
| */ | */ | ||||
| public void setFilesonly( final boolean filesonly ) | public void setFilesonly( final boolean filesonly ) | ||||
| { | { | ||||
| @@ -157,8 +155,6 @@ public class Zip | |||||
| /** | /** | ||||
| * Sets whether we want to update the file (if it exists) or create a new | * Sets whether we want to update the file (if it exists) or create a new | ||||
| * one. | * one. | ||||
| * | |||||
| * @param c The new Update value | |||||
| */ | */ | ||||
| public void setUpdate( final boolean update ) | public void setUpdate( final boolean update ) | ||||
| { | { | ||||
| @@ -527,15 +523,12 @@ public class Zip | |||||
| } | } | ||||
| for( int i = 0; i < dirs.length; i++ ) | for( int i = 0; i < dirs.length; i++ ) | ||||
| { | { | ||||
| if( "".equals( dirs[ i ] ) ) | |||||
| final String dir = dirs[ i ]; | |||||
| if( "".equals( dir ) ) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| String name = dirs[ i ].replace( File.separatorChar, '/' ); | |||||
| if( !name.endsWith( "/" ) ) | |||||
| { | |||||
| name += "/"; | |||||
| } | |||||
| final String name = getName( dir ); | |||||
| addParentDirs( thisBaseDir, name, zOut, prefix ); | addParentDirs( thisBaseDir, name, zOut, prefix ); | ||||
| } | } | ||||
| @@ -564,6 +557,16 @@ public class Zip | |||||
| } | } | ||||
| } | } | ||||
| private String getName( final String dir ) | |||||
| { | |||||
| String name = dir.replace( File.separatorChar, '/' ); | |||||
| if( !name.endsWith( "/" ) ) | |||||
| { | |||||
| name += "/"; | |||||
| } | |||||
| return name; | |||||
| } | |||||
| /** | /** | ||||
| * Iterate over the given ArrayList of (zip)filesets and add all files to the | * Iterate over the given ArrayList of (zip)filesets and add all files to the | ||||
| * ZipOutputStream using the given prefix or fullpath. | * ZipOutputStream using the given prefix or fullpath. | ||||
| @@ -587,16 +590,10 @@ public class Zip | |||||
| if( fs instanceof ZipFileSet ) | if( fs instanceof ZipFileSet ) | ||||
| { | { | ||||
| ZipFileSet zfs = (ZipFileSet)fs; | ZipFileSet zfs = (ZipFileSet)fs; | ||||
| prefix = zfs.getPrefix(); | |||||
| prefix = getPrefix( zfs.getPrefix() ); | |||||
| fullpath = zfs.getFullpath(); | fullpath = zfs.getFullpath(); | ||||
| } | } | ||||
| if( prefix.length() > 0 | |||||
| && !prefix.endsWith( "/" ) | |||||
| && !prefix.endsWith( "\\" ) ) | |||||
| { | |||||
| prefix += "/"; | |||||
| } | |||||
| // Need to manually add either fullpath's parent directory, or | // Need to manually add either fullpath's parent directory, or | ||||
| // the prefix directory, to the archive. | // the prefix directory, to the archive. | ||||
| @@ -623,6 +620,18 @@ public class Zip | |||||
| } | } | ||||
| } | } | ||||
| private String getPrefix( final String prefix ) | |||||
| { | |||||
| String result = prefix; | |||||
| if( result.length() > 0 | |||||
| && !result.endsWith( "/" ) | |||||
| && !result.endsWith( "\\" ) ) | |||||
| { | |||||
| result += "/"; | |||||
| } | |||||
| return result; | |||||
| } | |||||
| /** | /** | ||||
| * Ensure all parent dirs of a given entry have been added. | * Ensure all parent dirs of a given entry have been added. | ||||
| * | * | ||||
| @@ -111,7 +111,7 @@ public class Zip | |||||
| /** | /** | ||||
| * Sets whether we want to compress the files or only store them. | * Sets whether we want to compress the files or only store them. | ||||
| * | * | ||||
| * @param c The new Compress value | |||||
| * @param compress The new Compress value | |||||
| */ | */ | ||||
| public void setCompress( final boolean compress ) | public void setCompress( final boolean compress ) | ||||
| { | { | ||||
| @@ -146,8 +146,6 @@ public class Zip | |||||
| /** | /** | ||||
| * Emulate Sun's jar utility by not adding parent dirs | * Emulate Sun's jar utility by not adding parent dirs | ||||
| * | |||||
| * @param f The new Filesonly value | |||||
| */ | */ | ||||
| public void setFilesonly( final boolean filesonly ) | public void setFilesonly( final boolean filesonly ) | ||||
| { | { | ||||
| @@ -157,8 +155,6 @@ public class Zip | |||||
| /** | /** | ||||
| * Sets whether we want to update the file (if it exists) or create a new | * Sets whether we want to update the file (if it exists) or create a new | ||||
| * one. | * one. | ||||
| * | |||||
| * @param c The new Update value | |||||
| */ | */ | ||||
| public void setUpdate( final boolean update ) | public void setUpdate( final boolean update ) | ||||
| { | { | ||||
| @@ -527,15 +523,12 @@ public class Zip | |||||
| } | } | ||||
| for( int i = 0; i < dirs.length; i++ ) | for( int i = 0; i < dirs.length; i++ ) | ||||
| { | { | ||||
| if( "".equals( dirs[ i ] ) ) | |||||
| final String dir = dirs[ i ]; | |||||
| if( "".equals( dir ) ) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| String name = dirs[ i ].replace( File.separatorChar, '/' ); | |||||
| if( !name.endsWith( "/" ) ) | |||||
| { | |||||
| name += "/"; | |||||
| } | |||||
| final String name = getName( dir ); | |||||
| addParentDirs( thisBaseDir, name, zOut, prefix ); | addParentDirs( thisBaseDir, name, zOut, prefix ); | ||||
| } | } | ||||
| @@ -564,6 +557,16 @@ public class Zip | |||||
| } | } | ||||
| } | } | ||||
| private String getName( final String dir ) | |||||
| { | |||||
| String name = dir.replace( File.separatorChar, '/' ); | |||||
| if( !name.endsWith( "/" ) ) | |||||
| { | |||||
| name += "/"; | |||||
| } | |||||
| return name; | |||||
| } | |||||
| /** | /** | ||||
| * Iterate over the given ArrayList of (zip)filesets and add all files to the | * Iterate over the given ArrayList of (zip)filesets and add all files to the | ||||
| * ZipOutputStream using the given prefix or fullpath. | * ZipOutputStream using the given prefix or fullpath. | ||||
| @@ -587,16 +590,10 @@ public class Zip | |||||
| if( fs instanceof ZipFileSet ) | if( fs instanceof ZipFileSet ) | ||||
| { | { | ||||
| ZipFileSet zfs = (ZipFileSet)fs; | ZipFileSet zfs = (ZipFileSet)fs; | ||||
| prefix = zfs.getPrefix(); | |||||
| prefix = getPrefix( zfs.getPrefix() ); | |||||
| fullpath = zfs.getFullpath(); | fullpath = zfs.getFullpath(); | ||||
| } | } | ||||
| if( prefix.length() > 0 | |||||
| && !prefix.endsWith( "/" ) | |||||
| && !prefix.endsWith( "\\" ) ) | |||||
| { | |||||
| prefix += "/"; | |||||
| } | |||||
| // Need to manually add either fullpath's parent directory, or | // Need to manually add either fullpath's parent directory, or | ||||
| // the prefix directory, to the archive. | // the prefix directory, to the archive. | ||||
| @@ -623,6 +620,18 @@ public class Zip | |||||
| } | } | ||||
| } | } | ||||
| private String getPrefix( final String prefix ) | |||||
| { | |||||
| String result = prefix; | |||||
| if( result.length() > 0 | |||||
| && !result.endsWith( "/" ) | |||||
| && !result.endsWith( "\\" ) ) | |||||
| { | |||||
| result += "/"; | |||||
| } | |||||
| return result; | |||||
| } | |||||
| /** | /** | ||||
| * Ensure all parent dirs of a given entry have been added. | * Ensure all parent dirs of a given entry have been added. | ||||
| * | * | ||||