changeset 10601:e46b51de549a

[gaim-migrate @ 12028] This makes us use wgaim_rename() as g_rename(), its ugly, but it allows us to rename to an existing new file. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 16 Feb 2005 03:57:23 +0000
parents 9887014b7390
children f52ab405f1ab
files src/win32/libc_interface.c src/win32/libc_interface.h
diffstat 2 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/win32/libc_interface.c	Tue Feb 15 02:20:27 2005 +0000
+++ b/src/win32/libc_interface.c	Wed Feb 16 03:57:23 2005 +0000
@@ -34,9 +34,12 @@
 #include <glib.h>
 #include "debug.h"
 #include "libc_internal.h"
-
-#if !GLIB_CHECK_VERSION(2,6,0)
-#	define g_remove remove
+#if GLIB_CHECK_VERSION(2,6,0)
+# include <glib/gstdio.h>
+#else
+#define g_remove remove
+#define g_rename rename
+#define g_stat stat
 #endif
 /*
  *  PROTOS
@@ -312,17 +315,16 @@
 
 /* stdio.h */
 
-#if !GLIB_CHECK_VERSION(2,6,0)
 int wgaim_rename (const char *oldname, const char *newname) {
-	struct _stat oldstat, newstat;
+	struct stat oldstat, newstat;
 
-	if(_stat(oldname, &oldstat) == 0) {
+	if(g_stat(oldname, &oldstat) == 0) {
 		/* newname exists */
-		if(_stat(newname, &newstat) == 0) {
+		if(g_stat(newname, &newstat) == 0) {
 			/* oldname is a dir */
 			if(_S_ISDIR(oldstat.st_mode)) {
 				if(!_S_ISDIR(newstat.st_mode)) {
-					return rename(oldname, newname);
+					return g_rename(oldname, newname);
 				}
 				/* newname is a dir */
 				else {
@@ -331,7 +333,7 @@
 					   deleted and oldname should be renamed.
 					*/
 					gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "wgaim_rename does not behave here as it should\n");
-					return rename(oldname, newname);
+					return g_rename(oldname, newname);
 				}
 			}
 			/* oldname is not a dir */
@@ -344,13 +346,13 @@
 				/* newname is not a dir */
 				else {
 					g_remove(newname);
-					return rename(oldname, newname);
+					return g_rename(oldname, newname);
 				}
 			}
 		}
 		/* newname doesn't exist */
 		else
-			return rename(oldname, newname);
+			return g_rename(oldname, newname);
 	}
 	else {
 		/* oldname doesn't exist */
@@ -359,7 +361,6 @@
 	}
 
 }
-#endif
 
 /* time.h */
 
--- a/src/win32/libc_interface.h	Tue Feb 15 02:20:27 2005 +0000
+++ b/src/win32/libc_interface.h	Wed Feb 16 03:57:23 2005 +0000
@@ -125,12 +125,19 @@
 #define snprintf _snprintf
 #define vsnprintf _vsnprintf
 
-#if !GLIB_CHECK_VERSION(2,6,0)
-/* I think that this can probably go away, in favor of g_rename() */
 extern int wgaim_rename(const char *oldname, const char *newname);
 #define rename( oldname, newname ) \
 wgaim_rename( oldname, newname )
+
+#if GLIB_CHECK_VERSION(2,6,0)
+#ifdef g_rename
+# undef g_rename
 #endif
+/* This is necessary because we want rename on win32 to be able to overwrite an existing file, it is done in internal.h if GLib < 2.6*/
+#define g_rename(oldname, newname) \
+wgaim_rename(oldname, newname)
+#endif
+
 
 /* sys/stat.h */