Commit 2f9a2cd7 by Mark Mitchell Committed by Mark Mitchell

jcf-write.c (write_classfile): Unlink the temporary file if it cannot be renamed.

	* 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

From-SVN: r53439
parent 546c093e
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> 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. temporary file and then rename it.
2002-05-07 Tom Tromey <tromey@redhat.com> 2002-05-07 Tom Tromey <tromey@redhat.com>
......
...@@ -3380,9 +3380,7 @@ write_classfile (clas) ...@@ -3380,9 +3380,7 @@ write_classfile (clas)
/* The .class file is initially written to a ".tmp" file so that /* The .class file is initially written to a ".tmp" file so that
if multiple instances of the compiler are running at once if multiple instances of the compiler are running at once
they do not see partially formed class files. */ they do not see partially formed class files. */
temporary_file_name = xmalloc (strlen (class_file_name) temporary_file_name = concat (class_file_name, ".tmp", NULL);
+ strlen (".tmp") + 1);
sprintf (temporary_file_name, "%s.tmp", class_file_name);
stream = fopen (temporary_file_name, "wb"); stream = fopen (temporary_file_name, "wb");
if (stream == NULL) if (stream == NULL)
fatal_io_error ("can't open %s for writing", temporary_file_name); fatal_io_error ("can't open %s for writing", temporary_file_name);
...@@ -3394,7 +3392,10 @@ write_classfile (clas) ...@@ -3394,7 +3392,10 @@ write_classfile (clas)
if (fclose (stream)) if (fclose (stream))
fatal_io_error ("error closing %s", temporary_file_name); fatal_io_error ("error closing %s", temporary_file_name);
if (rename (temporary_file_name, class_file_name) == -1) 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 (temporary_file_name);
free (class_file_name); free (class_file_name);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment