# HG changeset patch # User Daniel Atallah # Date 1108526243 0 # Node ID e46b51de549a1f24bb0cc3fb4d02baafd905affa # Parent 9887014b7390c686e6b45fb77bba91d3983d30de [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 diff -r 9887014b7390 -r e46b51de549a src/win32/libc_interface.c --- 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 #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 +#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 */ diff -r 9887014b7390 -r e46b51de549a src/win32/libc_interface.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 */