Why is GCJ shy of overwriting a .class file?
Andrew Haley
aph@redhat.com
Fri Nov 8 06:06:00 GMT 2002
Ranjit Mathew writes:
>
> I read the MSDN documentation and found that MSVCRT
> would return an error for rename( ) if the file
> already exists, unlike Unix.
>
> How does the following look?
> --------------------------- 8< -----------------------------------
> --- jcf-write.c Fri Nov 8 17:00:02 2002
> +++ jcf-write.c Fri Nov 8 17:02:34 2002
> @@ -3423,4 +3423,8 @@
> if (fclose (stream))
> fatal_io_error ("error closing %s", temporary_file_name);
> +
> + /* On Win32, renaming to an existing file is an error */
> + remove (class_file_name);
> +
> if (rename (temporary_file_name, class_file_name) == -1)
> {
> --------------------------- 8< -----------------------------------
OK.
I'd add more commentary:
/* 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. */
Andrew.
More information about the Java
mailing list