This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: [WAS: Re: Why is GCJ shy of overwriting a .class file?]
- From: Ranjit Mathew <rmathew at hotmail dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Sun, 10 Nov 2002 21:04:17 +0530
- Subject: Re: Patch: [WAS: Re: Why is GCJ shy of overwriting a .class file?]
- References: <aqg47v$eq8$1@main.gmane.org> <15819.38400.682938.635422@cuddles.cambridge.redhat.com> <aqg5uq$kg4$1@main.gmane.org> <aqg7jp$pjk$1@main.gmane.org> <15819.43037.411109.59361@cuddles.cambridge.redhat.com> <3DCBAE30.4090100@hotmail.com> <87el9weyd2.fsf@fleche.redhat.com>
Tom Tromey wrote:
Ranjit> + remove (class_file_name);
The rest of gcc uses unlink().
Thanks for pointing that out. Not only is it more consistent
with the rest of GCC, but it is really what we want to
do for the rename( ) to succeed.
So here's the modified patch:
ChangeLog:
2002-11-08 Ranjit Mathew <rmathew@hotmail.com>,
Andrew Haley <aph@redhat.com>
* gcc/java/jcf-write.c (write_classfile): Remove target
class file, if it exists, before renaming the temporary
class file to it.
--------------------------- 8< -----------------------------
--- jcf-write.c Fri Nov 8 17:00:02 2002
+++ jcf-write.c Fri Nov 8 17:52:25 2002
@@ -3423,4 +3423,13 @@
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)
{
--------------------------- 8< -----------------------------
Ranjit.
--
Ranjit Mathew Email: rmathew AT hotmail DOT com
Bangalore,
INDIA. Web: http://ranjitmathew.tripod.com/