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

Ranjit Mathew rmathew@hotmail.com
Tue Nov 19 22:28:00 GMT 2002


Hi,

     If there's nothing wrong with this patch, can someone
please check this in?

Thanks.

Sincerely Yours,
Ranjit.

Ranjit Mathew wrote:
> 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/





More information about the Java-patches mailing list