From: Jan Nieuwenhuizen 2011-02-15 Jan Nieuwenhuizen * libguile/filesys.c [MINGW32] (my_rename): Add implementation that deletes target if it exists. Fixes rename behaviour. --- libguile/filesys.c | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libguile/filesys.c b/libguile/filesys.c index 880ee86..a2be2d5 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -680,9 +680,10 @@ SCM_DEFINE (scm_link, "link", 2, 0, 0, #undef FUNC_NAME #endif /* HAVE_LINK */ -#ifdef HAVE_RENAME +#if defined (HAVE_RENAME) && !defined (__MINGW32__) #define my_rename rename -#else +#else /* !HAVE_RENAME || __MINGW32__ */ +#ifndef __MINGW32__ static int my_rename (const char *oldname, const char *newname) { @@ -698,7 +699,24 @@ my_rename (const char *oldname, const char *newname) } return rv; } -#endif +#else /* __MINGW32__ */ +static int +my_rename (const char *oldname, const char *newname) +{ + int rv; + struct stat stat; + + SCM_SYSCALL (rv = !stat (newname, &stat)); + if (rv != 0) + SCM_SYSCALL (rv = unlink (newname)); + if (rv == 0) + rv = rename (oldname, newname); + + return rv; +} +#endif /* __MINGW32__ */ +#endif /* !HAVE_RENAME || __MINGW32__ */ + SCM_DEFINE (scm_rename, "rename-file", 2, 0, 0, (SCM oldname, SCM newname), -- 1.7.1 -- Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.nl