This simplifies the temp file solution I committed on Thursday, creating the temporary file in the same directory as the original as suggested by Tom Tromey.
ChangeLog: 2008-06-28 Andrew John Hughes <[EMAIL PROTECTED]> 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. -- Andrew :) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint = F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8
Index: tools/gnu/classpath/tools/jar/Updater.java =================================================================== RCS file: /sources/classpath/classpath/tools/gnu/classpath/tools/jar/Updater.java,v retrieving revision 1.5 diff -u -u -r1.5 Updater.java --- tools/gnu/classpath/tools/jar/Updater.java 26 Jun 2008 22:26:27 -0000 1.5 +++ tools/gnu/classpath/tools/jar/Updater.java 28 Jun 2008 19:44:50 -0000 @@ -71,7 +71,8 @@ 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 @@ 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(); - } - }