[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/5] [mingw]: Delete existing target file before attempting renam
From: |
Jan Nieuwenhuizen |
Subject: |
[PATCH 4/5] [mingw]: Delete existing target file before attempting rename. |
Date: |
Tue, 15 Feb 2011 16:35:02 +0100 |
From: Jan Nieuwenhuizen <address@hidden>
2011-02-15 Jan Nieuwenhuizen <address@hidden>
* 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 <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl
- mingw runtime patches, Jan Nieuwenhuizen, 2011/02/15
- [PATCH 4/5] [mingw]: Delete existing target file before attempting rename.,
Jan Nieuwenhuizen <=
- [PATCH 2/5] [mingw]: Have compiled-file-name produce valid names., Jan Nieuwenhuizen, 2011/02/15
- [PATCH 1/5] [mingw]: Add implementation of canonicalize_file_name., Jan Nieuwenhuizen, 2011/02/15
- [PATCH 3/5] [mingw]: Do not export opendir, readdir etc., as dirents differ., Jan Nieuwenhuizen, 2011/02/15
- [PATCH 5/5] [mingw]: Use $LOCALAPPDATA as a possible root for cachedir., Jan Nieuwenhuizen, 2011/02/15