18 #ifndef MAGICKCORE_UTILITY_PRIVATE_H
19 #define MAGICKCORE_UTILITY_PRIVATE_H
25 #if defined(__cplusplus) || defined(c_plusplus)
45 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
46 static inline wchar_t *create_wchar_path(
const char *utf8)
54 count=MultiByteToWideChar(CP_UTF8,0,utf8,-1,NULL,0);
55 if ((count > MAX_PATH) && (NTLongPathsEnabled() ==
MagickFalse))
67 if (longPath == (
wchar_t *) NULL)
68 return((
wchar_t *) NULL);
69 count=MultiByteToWideChar(CP_UTF8,0,buffer,-1,longPath,count);
71 count=GetShortPathNameW(longPath,shortPath,MAX_PATH);
73 if ((count < 5) || (count >= MAX_PATH))
74 return((
wchar_t *) NULL);
76 wcscpy(wideChar,shortPath+4);
80 if (wideChar == (
wchar_t *) NULL)
81 return((
wchar_t *) NULL);
82 count=MultiByteToWideChar(CP_UTF8,0,utf8,-1,wideChar,count);
86 return((
wchar_t *) NULL);
94 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__)
95 return(access(path,mode));
103 path_wide=create_wchar_path(path);
104 if (path_wide == (
wchar_t *) NULL)
106 status=_waccess(path_wide,mode);
114 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__)
115 return(fopen(path,mode));
124 path_wide=create_wchar_path(path);
125 if (path_wide == (
wchar_t *) NULL)
126 return((FILE *) NULL);
127 mode_wide=create_wchar_path(mode);
128 if (mode_wide == (
wchar_t *) NULL)
131 return((FILE *) NULL);
133 file=_wfopen(path_wide,mode_wide);
142 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__)
146 directory=getcwd(path,extent);
153 (void) WideCharToMultiByte(CP_UTF8,0,wide_path,-1,path,(
int) extent,NULL,NULL);
157 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__CYGWIN__) && !defined(__MINGW32__)
164 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__)
165 return(open(path,flags,mode));
173 path_wide=create_wchar_path(path);
174 if (path_wide == (
wchar_t *) NULL)
176 status=_wopen(path_wide,flags,mode);
182 static inline FILE *
popen_utf8(
const char *command,
const char *type)
184 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__)
185 return(popen(command,type));
198 length=MultiByteToWideChar(CP_UTF8,0,type,-1,type_wide,5);
201 length=MultiByteToWideChar(CP_UTF8,0,command,-1,NULL,0);
205 if (command_wide == (
wchar_t *) NULL)
207 length=MultiByteToWideChar(CP_UTF8,0,command,-1,command_wide,length);
209 file=_wpopen(command_wide,type_wide);
217 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__)
218 return(unlink(path));
226 path_wide=create_wchar_path(path);
227 if (path_wide == (
wchar_t *) NULL)
229 status=_wremove(path_wide);
235 static inline int rename_utf8(
const char *source,
const char *destination)
237 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__)
238 return(rename(source,destination));
247 source_wide=create_wchar_path(source);
248 if (source_wide == (
wchar_t *) NULL)
250 destination_wide=create_wchar_path(destination);
251 if (destination_wide == (
wchar_t *) NULL)
256 status=_wrename(source_wide,destination_wide);
265 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__)
266 return(stat(path,attributes));
274 path_wide=create_wchar_path(path);
275 if (path_wide == (WCHAR *) NULL)
277 status=wstat(path_wide,attributes);
283 #if defined(__cplusplus) || defined(c_plusplus)
static FILE * popen_utf8(const char *command, const char *type)
Definition: utility-private.h:182
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:497
static void getcwd_utf8(char *path, size_t extent)
Definition: utility-private.h:140
char * path
Definition: type.h:56
static int stat_utf8(const char *path, struct stat *attributes)
Definition: utility-private.h:263
MagickBooleanType
Definition: magick-type.h:198
static int remove_utf8(const char *path)
Definition: utility-private.h:215
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:665
static FILE * fopen_utf8(const char *path, const char *mode)
Definition: utility-private.h:112
#define MaxTextExtent
Definition: method-attribute.h:89
static int open_utf8(const char *path, int flags, mode_t mode)
Definition: utility-private.h:162
MagickPrivate MagickBooleanType ShredFile(const char *)
Definition: utility.c:1843
Definition: magick-type.h:200
MagickExport struct dirent * readdir(DIR *)
static int rename_utf8(const char *source, const char *destination)
Definition: utility-private.h:235
static int access_utf8(const char *path, int mode)
Definition: utility-private.h:92
static int MagickReadDirectory(DIR *directory, struct dirent *entry, struct dirent **result)
Definition: utility-private.h:32
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1162
#define MagickPrivate
Definition: method-attribute.h:81