Browse Source

Remove whitespace at end of lines.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269723 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
effcb7ade9
1 changed files with 42 additions and 42 deletions
  1. +42
    -42
      src/main/org/apache/tools/ant/taskdefs/Zip.java

+ 42
- 42
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 1999 The Apache Software Foundation. All rights
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met: * are met:
* *
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
@@ -17,15 +17,15 @@
* distribution. * distribution.
* *
* 3. The end-user documentation included with the redistribution, if * 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)." * Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself, * Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear. * if and wherever such third-party acknowlegements normally appear.
* *
* 4. The names "The Jakarta Project", "Ant", and "Apache Software * 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived * Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* from this software without prior written permission. For written
* permission, please contact apache@apache.org. * permission, please contact apache@apache.org.
* *
* 5. Products derived from this software may not be called "Apache" * 5. Products derived from this software may not be called "Apache"
@@ -87,12 +87,12 @@ public class Zip extends MatchingTask {
private Vector filesets = new Vector (); private Vector filesets = new Vector ();
private Hashtable addedDirs = new Hashtable(); private Hashtable addedDirs = new Hashtable();
private Vector addedFiles = new Vector(); private Vector addedFiles = new Vector();
/** true when we are adding new files into the Zip file, as opposed to
/** true when we are adding new files into the Zip file, as opposed to
adding back the unchanged files */ adding back the unchanged files */
private boolean addingNewFiles; private boolean addingNewFiles;
/** /**
* Encoding to use for filenames, defaults to the platform's * Encoding to use for filenames, defaults to the platform's
* default encoding. * default encoding.
@@ -100,7 +100,7 @@ public class Zip extends MatchingTask {
private String encoding = null; private String encoding = null;


/** /**
* This is the name/location of where to
* This is the name/location of where to
* create the .zip file. * create the .zip file.
* *
* @deprecated Use setFile() instead * @deprecated Use setFile() instead
@@ -109,18 +109,18 @@ public class Zip extends MatchingTask {
log("DEPRECATED - The zipfile attribute is deprecated. Use file attribute instead."); log("DEPRECATED - The zipfile attribute is deprecated. Use file attribute instead.");
setFile( zipFile ); setFile( zipFile );
} }
/** /**
* This is the name/location of where to
* This is the name/location of where to
* create the .zip file. * create the .zip file.
* *
*/ */
public void setFile(File file) { public void setFile(File file) {
this.zipFile = file; this.zipFile = file;
} }
/** /**
* This is the base directory to look in for
* This is the base directory to look in for
* things to zip. * things to zip.
*/ */
public void setBasedir(File baseDir) { public void setBasedir(File baseDir) {
@@ -198,7 +198,7 @@ public class Zip extends MatchingTask {


public void execute() throws BuildException { public void execute() throws BuildException {
if (baseDir == null && filesets.size() == 0 && "zip".equals(archiveType)) { if (baseDir == null && filesets.size() == 0 && "zip".equals(archiveType)) {
throw new BuildException( "basedir attribute must be set, or at least " +
throw new BuildException( "basedir attribute must be set, or at least " +
"one fileset must be given!" ); "one fileset must be given!" );
} }


@@ -210,18 +210,18 @@ public class Zip extends MatchingTask {
File renamedFile = null; File renamedFile = null;
// Whether or not an actual update is required - // Whether or not an actual update is required -
// we don't need to update if the original file doesn't exist // we don't need to update if the original file doesn't exist
addingNewFiles = true; addingNewFiles = true;
boolean reallyDoUpdate = false; boolean reallyDoUpdate = false;
if (doUpdate && zipFile.exists()) if (doUpdate && zipFile.exists())
{ {
reallyDoUpdate = true; reallyDoUpdate = true;
int i; int i;
for (i=0; i < 1000; i++) for (i=0; i < 1000; i++)
{ {
renamedFile = new File(zipFile.getParent(), "tmp."+i); renamedFile = new File(zipFile.getParent(), "tmp."+i);
if (!renamedFile.exists()) { if (!renamedFile.exists()) {
break; break;
} }
@@ -229,7 +229,7 @@ public class Zip extends MatchingTask {
if (i == 1000) { if (i == 1000) {
throw new BuildException("Can't find available temporary filename to which to rename old file."); throw new BuildException("Can't find available temporary filename to which to rename old file.");
} }
try try
{ {
if (!zipFile.renameTo(renamedFile)) { if (!zipFile.renameTo(renamedFile)) {
@@ -241,7 +241,7 @@ public class Zip extends MatchingTask {
throw new BuildException("Not allowed to rename old file to temporary file"); throw new BuildException("Not allowed to rename old file to temporary file");
} }
} }
// Create the scanners to pass to isUpToDate(). // Create the scanners to pass to isUpToDate().
Vector dss = new Vector (); Vector dss = new Vector ();
if (baseDir != null) { if (baseDir != null) {
@@ -262,12 +262,12 @@ public class Zip extends MatchingTask {
} }


String action = reallyDoUpdate ? "Updating " : "Building "; String action = reallyDoUpdate ? "Updating " : "Building ";
log(action + archiveType +": "+ zipFile.getAbsolutePath()); log(action + archiveType +": "+ zipFile.getAbsolutePath());


boolean success = false; boolean success = false;
try { try {
ZipOutputStream zOut =
ZipOutputStream zOut =
new ZipOutputStream(new FileOutputStream(zipFile)); new ZipOutputStream(new FileOutputStream(zipFile));
zOut.setEncoding(encoding); zOut.setEncoding(encoding);
try { try {
@@ -288,7 +288,7 @@ public class Zip extends MatchingTask {
addingNewFiles = false; addingNewFiles = false;
ZipFileSet oldFiles = new ZipFileSet(); ZipFileSet oldFiles = new ZipFileSet();
oldFiles.setSrc(renamedFile); oldFiles.setSrc(renamedFile);
StringBuffer exclusionPattern = new StringBuffer(); StringBuffer exclusionPattern = new StringBuffer();
for (int i=0; i < addedFiles.size(); i++) for (int i=0; i < addedFiles.size(); i++)
{ {
@@ -311,11 +311,11 @@ public class Zip extends MatchingTask {
zOut.close(); zOut.close();
} }
} catch(IOException ex) { } catch(IOException ex) {
// If we're in this finally clause because of an exception, we don't
// If we're in this finally clause because of an exception, we don't
// really care if there's an exception when closing the stream. E.g. if it // really care if there's an exception when closing the stream. E.g. if it
// throws "ZIP file must have at least one entry", because an exception happened // throws "ZIP file must have at least one entry", because an exception happened
// before we added any files, then we must swallow this exception. Otherwise, // before we added any files, then we must swallow this exception. Otherwise,
// the error that's reported will be the close() error, which is not the real
// the error that's reported will be the close() error, which is not the real
// cause of the problem. // cause of the problem.
if (success) if (success)
throw ex; throw ex;
@@ -335,12 +335,12 @@ public class Zip extends MatchingTask {
renamedFile.getName()+" back)"; renamedFile.getName()+" back)";
} }
} }
throw new BuildException(msg, ioe, location); throw new BuildException(msg, ioe, location);
} finally { } finally {
cleanUp(); cleanUp();
} }
// If we've been successful on an update, delete the temporary file // If we've been successful on an update, delete the temporary file
if (success && reallyDoUpdate) { if (success && reallyDoUpdate) {
if (!renamedFile.delete()) { if (!renamedFile.delete()) {
@@ -357,14 +357,14 @@ public class Zip extends MatchingTask {
protected boolean isAddingNewFiles() { protected boolean isAddingNewFiles() {
return addingNewFiles; return addingNewFiles;
} }
/** /**
* Add all files of the given FileScanner to the ZipOutputStream * Add all files of the given FileScanner to the ZipOutputStream
* prependig the given prefix to each filename. * prependig the given prefix to each filename.
* *
* <p>Ensure parent directories have been added as well.
* <p>Ensure parent directories have been added as well.
*/ */
protected void addFiles(FileScanner scanner, ZipOutputStream zOut,
protected void addFiles(FileScanner scanner, ZipOutputStream zOut,
String prefix, String fullpath) throws IOException { String prefix, String fullpath) throws IOException {
if (prefix.length() > 0 && fullpath.length() > 0) if (prefix.length() > 0 && fullpath.length() > 0)
throw new BuildException("Both prefix and fullpath attributes may not be set on the same fileset."); throw new BuildException("Both prefix and fullpath attributes may not be set on the same fileset.");
@@ -477,8 +477,8 @@ public class Zip extends MatchingTask {
} }
return true; return true;
} }
/** /**
* Check whether the archive is up-to-date; and handle behavior for empty archives. * Check whether the archive is up-to-date; and handle behavior for empty archives.
* @param scanners list of prepared scanners containing files to archive * @param scanners list of prepared scanners containing files to archive
@@ -529,7 +529,7 @@ public class Zip extends MatchingTask {
return grabFiles(scanners, grabFileNames(scanners)); return grabFiles(scanners, grabFileNames(scanners));
} }


protected static File[] grabFiles(FileScanner[] scanners,
protected static File[] grabFiles(FileScanner[] scanners,
String[][] fileNames) { String[][] fileNames) {
Vector files = new Vector(); Vector files = new Vector();
for (int i = 0; i < fileNames.length; i++) { for (int i = 0; i < fileNames.length; i++) {
@@ -563,7 +563,7 @@ public class Zip extends MatchingTask {
return; return;
} }
addedDirs.put(vPath, vPath); addedDirs.put(vPath, vPath);
ZipEntry ze = new ZipEntry (vPath); ZipEntry ze = new ZipEntry (vPath);
if (dir != null && dir.exists()) { if (dir != null && dir.exists()) {
ze.setTime(dir.lastModified()); ze.setTime(dir.lastModified());
@@ -590,12 +590,12 @@ public class Zip extends MatchingTask {


/* /*
* XXX ZipOutputStream.putEntry expects the ZipEntry to know its * XXX ZipOutputStream.putEntry expects the ZipEntry to know its
* size and the CRC sum before you start writing the data when using
* size and the CRC sum before you start writing the data when using
* STORED mode. * STORED mode.
* *
* This forces us to process the data twice. * This forces us to process the data twice.
* *
* I couldn't find any documentation on this, just found out by try
* I couldn't find any documentation on this, just found out by try
* and error. * and error.
*/ */
if (!doCompress) { if (!doCompress) {
@@ -667,7 +667,7 @@ public class Zip extends MatchingTask {
if( !doFilesonly ) { if( !doFilesonly ) {
Stack directories = new Stack(); Stack directories = new Stack();
int slashPos = entry.length(); int slashPos = entry.length();
while ((slashPos = entry.lastIndexOf((int)'/', slashPos-1)) != -1) { while ((slashPos = entry.lastIndexOf((int)'/', slashPos-1)) != -1) {
String dir = entry.substring(0, slashPos+1); String dir = entry.substring(0, slashPos+1);
if (addedDirs.get(prefix+dir) != null) { if (addedDirs.get(prefix+dir) != null) {
@@ -675,7 +675,7 @@ public class Zip extends MatchingTask {
} }
directories.push(dir); directories.push(dir);
} }
while (!directories.isEmpty()) { while (!directories.isEmpty()) {
String dir = (String) directories.pop(); String dir = (String) directories.pop();
File f = null; File f = null;
@@ -707,15 +707,15 @@ public class Zip extends MatchingTask {
prefix = zfs.getPrefix(); prefix = zfs.getPrefix();
fullpath = zfs.getFullpath(); fullpath = zfs.getFullpath();
} }
if (prefix.length() > 0
if (prefix.length() > 0
&& !prefix.endsWith("/") && !prefix.endsWith("/")
&& !prefix.endsWith("\\")) { && !prefix.endsWith("\\")) {
prefix += "/"; prefix += "/";
} }


// Need to manually add either fullpath's parent directory, or
// the prefix directory, to the archive.
// Need to manually add either fullpath's parent directory, or
// the prefix directory, to the archive.
if (prefix.length() > 0) { if (prefix.length() > 0) {
addParentDirs(null, prefix, zOut, ""); addParentDirs(null, prefix, zOut, "");
zipDir(null, zOut, prefix); zipDir(null, zOut, prefix);


Loading…
Cancel
Save