+2002-05-13 Mark Mitchell <mark@codesourcery.com>
+
+ * jcf-write.c (write_classfile): Unlink the temporary file if it
+ cannot be renamed. Use concat to build up the name of the
+ temporary file.
+
2002-05-08 Mark Mitchell <mark@codesourcery.com>
- * java/jcf-write.c (write_classfile): Write the file to a
+ * jcf-write.c (write_classfile): Write the file to a
temporary file and then rename it.
2002-05-07 Tom Tromey <tromey@redhat.com>
/* The .class file is initially written to a ".tmp" file so that
if multiple instances of the compiler are running at once
they do not see partially formed class files. */
- temporary_file_name = xmalloc (strlen (class_file_name)
- + strlen (".tmp") + 1);
- sprintf (temporary_file_name, "%s.tmp", class_file_name);
+ temporary_file_name = concat (class_file_name, ".tmp", NULL);
stream = fopen (temporary_file_name, "wb");
if (stream == NULL)
fatal_io_error ("can't open %s for writing", temporary_file_name);
if (fclose (stream))
fatal_io_error ("error closing %s", temporary_file_name);
if (rename (temporary_file_name, class_file_name) == -1)
- fatal_io_error ("can't create %s", class_file_name);
+ {
+ remove (temporary_file_name);
+ fatal_io_error ("can't create %s", class_file_name);
+ }
free (temporary_file_name);
free (class_file_name);
}