summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2008-06-28 19:48:01 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2008-06-28 19:48:01 +0000
commit8ecd0bc8ba9abf3b87ccadf3f87458b7fcfc943a (patch)
tree0d0a8513b7cd7badfcdc8bc6a9cfc84ac2774f8f /tools
parentd6e4f9fb2457086bac87975672c0c11f2d88f67f (diff)
downloadclasspath-8ecd0bc8ba9abf3b87ccadf3f87458b7fcfc943a.tar.gz
Simplify tempfile fix so the tempfile is just created in the same directory.
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.
Diffstat (limited to 'tools')
-rw-r--r--tools/gnu/classpath/tools/jar/Updater.java28
1 files changed, 4 insertions, 24 deletions
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();
- }
-
}