]> granicus.if.org Git - imagemagick/commitdiff
Fixed UTF8 issue when determining the current working directory on Windows.
authordirk <dirk@git.imagemagick.org>
Mon, 6 Apr 2015 16:49:12 +0000 (16:49 +0000)
committerdirk <dirk@git.imagemagick.org>
Mon, 6 Apr 2015 16:49:12 +0000 (16:49 +0000)
MagickCore/utility-private.h
MagickCore/utility.c

index 4f0411a894e557aa57d2383008b7972e2cc93d2d..3ff6bb4a30af4288036f5c4f1c01c883b827d480 100644 (file)
@@ -141,6 +141,23 @@ static inline FILE *fopen_utf8(const char *path,const char *mode)
 #endif
 }
 
+static inline void getcwd_utf8(char *path,size_t extent)
+{
+#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
+  char
+    *directory;
+
+   directory=getcwd(path,extent);
+   (void) directory;
+#else
+  wchar_t
+    wide_path[MaxTextExtent];
+
+  (void) _wgetcwd(wide_path,MaxTextExtent-1);
+  (void) WideCharToMultiByte(CP_UTF8,0,wide_path,-1,path,(int) extent,NULL,NULL);
+#endif
+}
+
 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__)
 typedef int
   mode_t;
index bd5d1954ab63d323cac1f1f2cd8d76f71bb22bfc..9ccacb112856b7fad2a9080cf020f063cb6d456f 100644 (file)
@@ -722,7 +722,6 @@ MagickExport MagickBooleanType ExpandFilenames(int *number_arguments,
   char ***arguments)
 {
   char
-    *directory,
     home_directory[MaxTextExtent],
     **vector;
 
@@ -809,8 +808,7 @@ MagickExport MagickBooleanType ExpandFilenames(int *number_arguments,
         GetPathComponent(option,SubimagePath,subimage);
         ExpandFilename(path);
         if (*home_directory == '\0')
-          directory=getcwd(home_directory,MaxTextExtent-1);
-        (void) directory;
+          getcwd_utf8(home_directory,MaxTextExtent-1);
         filelist=ListFiles(*path == '\0' ? home_directory : path,filename,
           &number_files);
       }