[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Fix rename-file behavior on Windows when d

From: Michele La Monaca
Subject: Re: [Chicken-hackers] [PATCH] Fix rename-file behavior on Windows when destination exists
Date: Tue, 14 Oct 2014 18:45:40 +0200

On Sun, Oct 5, 2014 at 8:31 PM, Peter Bex <address@hidden> wrote:
> On Mon, Aug 18, 2014 at 04:34:23PM +0200, Michele La Monaca wrote:
>> Hi,
>> (rename-file "x" "y")
>> fails on Windows if "y" already exists. I think it would be better to have 
>> the
>> same behavior as Unix (i.e. overwrite). The attached patch does that.
> Hi Michele,
> Sorry for the late reply, I've only now gotten around to looking at
> your patch.  Unfortunately, your patch doesn't work correctly when
> the move fails: MoveFileEx does not set errno, so the strerror call
> in library.scm will also not return the correct error message when
> this happens.
> Also, including windows.h from chicken.h seems a bit excessive.  Moving
> it to runtime.c is probably a better place for it (it is already included
> in that file).

Good idea.

> I think for now the wisest is to keep the current behaviour as it is.
> Perhaps for CHICKEN 5 someone(TM) can come up with a better way to
> do generic error handling that doesn't fail so badly when trying to
> use Windows-native functions.

Something like that?

/* offending code */
errno = EOTHER
MoveFileEx(...);     // or any other Windows API call

/* strerror (WIN32 only) */
if (errno == EOTHER) {
  DWORD dw = GetLastError();
} else

reply via email to

[Prev in Thread] Current Thread [Next in Thread]