From bbbf74122967c0ffeac0f9303920751f75255913 Mon Sep 17 00:00:00 2001
From: david_williams <david_williams>
Date: Tue, 10 Feb 2009 05:29:39 +0000
Subject: [PATCH] improve signing

---
 .../tools/UpdatePackPropertiesFile.java       | 70 ++++++++-----------
 1 file changed, 30 insertions(+), 40 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 bea05f8b7..a999853d5 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
@@ -160,7 +160,7 @@ public class UpdatePackPropertiesFile extends Task {
 		if (!success) {
 			throw new BuildException("Could not rename original zip file to backup name.");
 		}
-		
+
 		File newarchive = new File(tempzipFileName);
 		success = newarchive.renameTo(originalarchive);
 		if (!success) {
@@ -233,52 +233,33 @@ public class UpdatePackPropertiesFile extends Task {
 
 
 		for (int i = 0; i < files.length; i++) {
-			if (files[i].isDirectory()) {
-				String entryName = files[i].getCanonicalPath().substring(rootDirectory.length());
-				entryName = translate(entryName, '\\', "/");
-				if (!entryName.endsWith("/")) {
-					entryName = entryName + "/";
-				}
-
-				log(" Adding Directory Entry: " + entryName, Project.MSG_DEBUG);
-				out.putNextEntry(new ZipEntry(entryName));
-				// now recurse through the directory
-				addDir(files[i], out, rootDirectory);
-			}
-			else {
-				FileInputStream in = new FileInputStream(files[i].getAbsolutePath());
-
-				String entryName = files[i].getAbsolutePath().substring(rootDirectory.length());
-				log(" Adding: " + entryName, Project.MSG_DEBUG);
-
-				out.putNextEntry(new ZipEntry(entryName));
-
-				// Transfer from the file to the ZIP file
-				int len;
-				while ((len = in.read(tmpBuf)) > 0) {
-					out.write(tmpBuf, 0, len);
+			String entryName = files[i].getAbsolutePath().substring(rootDirectory.length());
+			if (!entryName.equals(".") && !entryName.equals("..")) {
+				entryName = slashify(entryName, files[i].isDirectory());
+				if (files[i].isDirectory()) {
+					log(" Adding Directory Entry: " + entryName); //, Project.MSG_DEBUG);
+					out.putNextEntry(new ZipEntry(entryName));
+					// now recurse through the directory
+					addDir(files[i], out, rootDirectory);
 				}
+				else {
+					FileInputStream in = new FileInputStream(files[i].getAbsolutePath());
+					log(" Adding: " + entryName); //, Project.MSG_DEBUG);
 
-				// Complete the entry
-				out.closeEntry();
-				in.close();
-			}
-		}
-	}
+					out.putNextEntry(new ZipEntry(entryName));
 
+					// Transfer from the file to the ZIP file
+					int len;
+					while ((len = in.read(tmpBuf)) > 0) {
+						out.write(tmpBuf, 0, len);
+					}
 
-	private String translate(String entryName, char c, String d) {
-		String result = entryName;
-		if (entryName.indexOf(c) > -1) {
-			StringBuffer tempHold = new StringBuffer(entryName);
-			for (int i = 0; i < tempHold.length(); i++) {
-				if (tempHold.charAt(i) == c) {
-					tempHold.replace(i, i+1, d);
+					// Complete the entry
+					out.closeEntry();
+					in.close();
 				}
 			}
-			result = tempHold.toString();
 		}
-		return result;
 	}
 
 	private String checkIfJarsSigned(String currentresults, String destinationDir, String parentDir, String[] jars) throws IOException {
@@ -361,4 +342,13 @@ public class UpdatePackPropertiesFile extends Task {
 		this.archiveFilename = archiveFilename;
 	}
 
+	private String slashify(String path, boolean isDirectory) {
+		String p = path;
+		if (File.separatorChar != '/')
+			p = p.replace(File.separatorChar, '/');
+
+		if (!p.endsWith("/") && isDirectory)
+			p = p + "/";
+		return p;
+	}
 }
-- 
GitLab