From 4ff28e04954312ef72d61ebabe0a92a1a5fe8358 Mon Sep 17 00:00:00 2001 From: david_williams <david_williams> Date: Mon, 23 Feb 2009 17:39:36 +0000 Subject: [PATCH] check for no zip file --- .../tools/UpdatePackPropertiesFile.java | 73 ++++++++++--------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/UpdatePackPropertiesFile.java b/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/UpdatePackPropertiesFile.java index cf1e7dd1b..2cfec3a0b 100644 --- a/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/UpdatePackPropertiesFile.java +++ b/plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/UpdatePackPropertiesFile.java @@ -286,51 +286,58 @@ public class UpdatePackPropertiesFile extends Task { byte[] buf = new byte[1024]; ZipInputStream zipinputstream = null; ZipEntry zipentry; - zipinputstream = new ZipInputStream(new FileInputStream(zipfilename)); - // make sure destination exists - File dir = new File(destinationdirectory); - boolean success = dir.mkdirs(); - if (success) { + File testFile = new File(zipfilename); + if (!testFile.exists()) { + log("Zip file, " + zipfilename + ", does not exist."); + } + else { + zipinputstream = new ZipInputStream(new FileInputStream(zipfilename)); + // make sure destination exists + File dir = new File(destinationdirectory); + boolean success = dir.mkdirs(); + if (success) { - zipentry = zipinputstream.getNextEntry(); - while (zipentry != null) { - // for each entry to be extracted - String entryName = zipentry.getName(); - log("entryname: " + entryName, Project.MSG_DEBUG); - int n; - FileOutputStream fileoutputstream; + zipentry = zipinputstream.getNextEntry(); + while (zipentry != null) { + // for each entry to be extracted + String entryName = zipentry.getName(); + log("entryname: " + entryName, Project.MSG_DEBUG); + int n; + FileOutputStream fileoutputstream; - String fullname = destinationdirectory + entryName; - if (zipentry.isDirectory()) { - // we assume folder entries come before their files. - // not sure that's always true? - File newDir = new File(fullname); - newDir.mkdirs(); - } - else { - File newFile = new File(fullname); - fileoutputstream = new FileOutputStream(newFile); + String fullname = destinationdirectory + entryName; + if (zipentry.isDirectory()) { + // we assume folder entries come before their files. + // not sure that's always true? + File newDir = new File(fullname); + newDir.mkdirs(); + } + else { + File newFile = new File(fullname); - while ((n = zipinputstream.read(buf, 0, 1024)) > -1) - fileoutputstream.write(buf, 0, n); - fileoutputstream.close(); - } + fileoutputstream = new FileOutputStream(newFile); - zipinputstream.closeEntry(); - zipentry = zipinputstream.getNextEntry(); + while ((n = zipinputstream.read(buf, 0, 1024)) > -1) + fileoutputstream.write(buf, 0, n); + fileoutputstream.close(); + } - }// while + zipinputstream.closeEntry(); + zipentry = zipinputstream.getNextEntry(); - zipinputstream.close(); - } + }// while - else { - throw new BuildException("Could not create directory: " + destinationdirectory); + zipinputstream.close(); + } + + else { + throw new BuildException("Could not create directory: " + destinationdirectory); + } } } -- GitLab