]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Fri, 23 Sep 2011 14:55:47 +0000 (14:55 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Fri, 23 Sep 2011 14:55:47 +0000 (14:55 +0000)
MagickCore/cache.c
MagickCore/utility-private.h
MagickWand/mogrify.c

index 8f02a6dca3785f573879d1fe8bbe914442db5c2f..c64769d49c81a5dbefe8aae3f8e66ac0c938362b 100644 (file)
@@ -4287,7 +4287,7 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image,
           /*
             Usurp existing persistent pixel cache.
           */
-          status=rename(cache_info->cache_filename,filename);
+          status=rename_utf8(cache_info->cache_filename,filename);
           if (status == 0)
             {
               (void) CopyMagickString(cache_info->cache_filename,filename,
index 5f5886fe0134596aed79ad148a8c857ce0eac66d..d3f8573bc7d23e4b3b5286a5483a59be4cb5edba 100644 (file)
@@ -73,9 +73,6 @@ static inline FILE *fopen_utf8(const char *path,const char *mode)
    FILE
      *file;
 
-   int
-     status;
-
    WCHAR
      *mode_wide,
      *path_wide;
@@ -133,9 +130,6 @@ static inline FILE *popen_utf8(const char *command,const char *type)
    FILE
      *file;
 
-   int
-     status;
-
    WCHAR
      *type_wide,
      *command_wide;
@@ -185,6 +179,43 @@ static inline int remove_utf8(const char *path)
 #endif
 }
 
+static inline int rename_utf8(const char *source,const char *destination)
+{
+#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__)
+  return(rename(source,destination));
+#else
+   FILE
+     *file;
+
+   int
+     status;
+
+   WCHAR
+     *destination_wide,
+     *source_wide;
+
+   source_wide=(WCHAR *) NULL;
+   count=MultiByteToWideChar(CP_UTF8,0,source,-1,NULL,0);
+   source_wide=(WCHAR *) AcquireQuantumMemory(count,sizeof(*source_wide));
+   if (source_wide == (WCHAR *) NULL)
+     return(-1);
+   count=MultiByteToWideChar(CP_UTF8,0,source,-1,source_wide,count);
+   count=MultiByteToWideChar(CP_UTF8,0,destination,-1,NULL,0);
+   destination_wide=(WCHAR *) AcquireQuantumMemory(count,
+     sizeof(*destination_wide));
+   if (destination_wide == (WCHAR *) NULL)
+     {
+       source_wide=RelinquishMagickMemory(source_wide);
+       return(-1);
+     }
+   count=MultiByteToWideChar(CP_UTF8,0,destination,-1,destination_wide,count);
+   status=_wrename(path_wide,destination_width);
+   destination_wide=RelinquishMagickMemory(destination_wide);
+   path_wide=RelinquishMagickMemory(path_wide);
+   return(status);
+#endif
+}
+
 static inline int stat_utf8(const char *path,struct stat *attributes)
 {
 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__)
index 0167c379053f8375c9a5fc5b6d29c34fa698689e..0b65e0801783b30383cc73180cce9600751a77a9 100644 (file)
@@ -3736,7 +3736,7 @@ WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
                 break;
             }
             if ((IsPathAccessible(backup_filename) != MagickFalse) ||
-                (rename(image->filename,backup_filename) != 0))
+                (rename_utf8(image->filename,backup_filename) != 0))
               *backup_filename='\0';
           }
         /*