diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | tools/gnu/classpath/tools/jar/Updater.java | 28 |
2 files changed, 13 insertions, 24 deletions
@@ -1,3 +1,12 @@ +2008-06-28 Andrew John Hughes <gnu_andrew@member.fsf.org> + + PR classpath/36636: + * tools/gnu/classpath/tools/jar/Updater.java: + (run(Main)): Check return value of renameTo, and + create temporary file in same directory (as suggested + by Tom Tromey). + (copyFile(File,File)): Removed. + 2008-06-27 Andrew John Hughes <gnu_andrew@member.fsf.org> PR classpath/36637: diff --git a/tools/gnu/classpath/tools/jar/Updater.java b/tools/gnu/classpath/tools/jar/Updater.java index a719004ed..f25d56fdc 100644 --- a/tools/gnu/classpath/tools/jar/Updater.java +++ b/tools/gnu/classpath/tools/jar/Updater.java @@ -71,7 +71,8 @@ public class Updater inputJar = new JarFile(parameters.archiveFile); // Write all the new entries to a temporary file. - File tmpFile = File.createTempFile("jarcopy", null); + File tmpFile = File.createTempFile("jarcopy", null, + parameters.archiveFile.getParentFile()); OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile)); writeCommandLineEntries(parameters, os); @@ -89,30 +90,9 @@ public class Updater close(); if (!tmpFile.renameTo(parameters.archiveFile)) { - if (!parameters.archiveFile.delete()) - throw new IOException("Couldn't delete original JAR file " + - parameters.archiveFile); - copyFile(tmpFile, parameters.archiveFile); - tmpFile.delete(); + throw new IOException("Couldn't rename new JAR file " + tmpFile + + "to " + parameters.archiveFile); } } - private void copyFile(File sourceFile, File destFile) - throws IOException - { - BufferedInputStream source = - new BufferedInputStream(new FileInputStream(sourceFile)); - BufferedOutputStream dest = - new BufferedOutputStream(new FileOutputStream(destFile)); - int inputByte; - - while ((inputByte = source.read()) != -1) - { - dest.write(inputByte); - } - - source.close(); - dest.close(); - } - } |