aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/jcf-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/java/jcf-write.c')
-rw-r--r--gcc/java/jcf-write.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c
index 1a9f107..47cfd11 100644
--- a/gcc/java/jcf-write.c
+++ b/gcc/java/jcf-write.c
@@ -3422,6 +3422,15 @@ write_classfile (clas)
write_chunks (stream, chunks);
if (fclose (stream))
fatal_io_error ("error closing %s", temporary_file_name);
+
+ /* If a file named by the string pointed to by `new' exists
+ prior to the call to the `rename' function, the bahaviour
+ is implementation-defined. ISO 9899-1990 7.9.4.2.
+
+ For example, on Win32 with MSVCRT, it is an error. */
+
+ unlink (class_file_name);
+
if (rename (temporary_file_name, class_file_name) == -1)
{
remove (temporary_file_name);