From: dirk Date: Mon, 6 Apr 2015 16:49:12 +0000 (+0000) Subject: Fixed UTF8 issue when determining the current working directory on Windows. X-Git-Tag: 7.0.1-0~1133 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2cc93c9c427929b244d983ae6241ca77bad2b88b;p=imagemagick Fixed UTF8 issue when determining the current working directory on Windows. --- diff --git a/MagickCore/utility-private.h b/MagickCore/utility-private.h index 4f0411a89..3ff6bb4a3 100644 --- a/MagickCore/utility-private.h +++ b/MagickCore/utility-private.h @@ -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; diff --git a/MagickCore/utility.c b/MagickCore/utility.c index bd5d1954a..9ccacb112 100644 --- a/MagickCore/utility.c +++ b/MagickCore/utility.c @@ -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); }