18 #ifndef MAGICKCORE_UTILITY_PRIVATE_H 19 #define MAGICKCORE_UTILITY_PRIVATE_H 25 #if defined(__cplusplus) || defined(c_plusplus) 36 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 37 static inline wchar_t *create_wchar_path(
const char *utf8)
45 count=MultiByteToWideChar(CP_UTF8,0,utf8,-1,NULL,0);
58 if (longPath == (
wchar_t *) NULL)
59 return((
wchar_t *) NULL);
60 count=MultiByteToWideChar(CP_UTF8,0,buffer,-1,longPath,count);
62 count=GetShortPathNameW(longPath,shortPath,MAX_PATH);
65 return((
wchar_t *) NULL);
67 wcscpy(wideChar,shortPath+4);
71 if (wideChar == (
wchar_t *) NULL)
72 return((
wchar_t *) NULL);
73 count=MultiByteToWideChar(CP_UTF8,0,utf8,-1,wideChar,count);
77 return((
wchar_t *) NULL);
85 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 86 return(access(path,mode));
94 path_wide=create_wchar_path(path);
95 if (path_wide == (
wchar_t *) NULL)
97 status=_waccess(path_wide,mode);
105 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) 106 return(fopen(path,mode));
115 path_wide=create_wchar_path(path);
116 if (path_wide == (
wchar_t *) NULL)
117 return((FILE *) NULL);
118 mode_wide=create_wchar_path(mode);
119 if (mode_wide == (
wchar_t *) NULL)
122 return((FILE *) NULL);
124 file=_wfopen(path_wide,mode_wide);
133 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) 137 directory=getcwd(path,extent);
144 (void) WideCharToMultiByte(CP_UTF8,0,wide_path,-1,path,(
int) extent,NULL,NULL);
148 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) 155 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) 156 return(open(path,flags,mode));
164 path_wide=create_wchar_path(path);
165 if (path_wide == (
wchar_t *) NULL)
167 status=_wopen(path_wide,flags,mode);
173 static inline FILE *
popen_utf8(
const char *command,
const char *type)
175 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) 176 return(popen(command,type));
185 command_wide=create_wchar_path(command);
186 if (command_wide == (
wchar_t *) NULL)
187 return((FILE *) NULL);
188 type_wide=create_wchar_path(type);
189 if (type_wide == (
wchar_t *) NULL)
192 return((FILE *) NULL);
194 file=_wpopen(command_wide,type_wide);
203 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) 204 return(unlink(path));
212 path_wide=create_wchar_path(path);
213 if (path_wide == (
wchar_t *) NULL)
215 status=_wremove(path_wide);
221 static inline int rename_utf8(
const char *source,
const char *destination)
223 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) 224 return(rename(source,destination));
233 source_wide=create_wchar_path(source);
234 if (source_wide == (
wchar_t *) NULL)
236 destination_wide=create_wchar_path(destination);
237 if (destination_wide == (
wchar_t *) NULL)
242 status=_wrename(source_wide,destination_wide);
251 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) 252 return(stat(path,attributes));
260 path_wide=create_wchar_path(path);
261 if (path_wide == (WCHAR *) NULL)
263 status=wstat(path_wide,attributes);
269 #if defined(__cplusplus) || defined(c_plusplus)
static FILE * popen_utf8(const char *command, const char *type)
Definition: utility-private.h:173
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:470
static void getcwd_utf8(char *path, size_t extent)
Definition: utility-private.h:131
char * path
Definition: type.h:55
static int stat_utf8(const char *path, struct stat *attributes)
Definition: utility-private.h:249
MagickBooleanType
Definition: magick-type.h:211
static int remove_utf8(const char *path)
Definition: utility-private.h:201
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:526
static FILE * fopen_utf8(const char *path, const char *mode)
Definition: utility-private.h:103
#define MaxTextExtent
Definition: method-attribute.h:106
static int open_utf8(const char *path, int flags, mode_t mode)
Definition: utility-private.h:153
MagickPrivate MagickBooleanType ShredFile(const char *)
Definition: utility.c:1787
static int rename_utf8(const char *source, const char *destination)
Definition: utility-private.h:221
static int access_utf8(const char *path, int mode)
Definition: utility-private.h:83
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:998
#define MagickPrivate
Definition: method-attribute.h:99