This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: [WAS: Re: Why is GCJ shy of overwriting a .class file?]


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/




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]