18 #ifndef MAGICKCORE_UTILITY_PRIVATE_H 19 #define MAGICKCORE_UTILITY_PRIVATE_H 25 #if defined(__cplusplus) || defined(c_plusplus) 31 **
ListFiles(
const char *,
const char *,
size_t *);
47 #if defined(MAGICKCORE_HAVE_READDIR_R) 48 return(readdir_r(directory,entry,result));
61 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 62 static inline wchar_t *create_wchar_path(
const char *utf8)
70 count=MultiByteToWideChar(CP_UTF8,0,utf8,-1,NULL,0);
71 if ((count > MAX_PATH) && (strncmp(utf8,
"\\\\?\\",4) != 0) &&
84 if (longPath == (
wchar_t *) NULL)
85 return((
wchar_t *) NULL);
86 count=MultiByteToWideChar(CP_UTF8,0,buffer,-1,longPath,count);
88 count=GetShortPathNameW(longPath,shortPath,MAX_PATH);
90 if ((count < 5) || (count >= MAX_PATH))
91 return((
wchar_t *) NULL);
93 wcscpy(wideChar,shortPath+4);
97 if (wideChar == (
wchar_t *) NULL)
98 return((
wchar_t *) NULL);
99 count=MultiByteToWideChar(CP_UTF8,0,utf8,-1,wideChar,count);
103 return((
wchar_t *) NULL);
111 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 112 return(access(path,mode));
120 path_wide=create_wchar_path(path);
121 if (path_wide == (
wchar_t *) NULL)
123 status=_waccess(path_wide,mode);
129 static inline FILE *
fopen_utf8(
const char *path,
const char *mode)
131 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 132 return(fopen(path,mode));
141 path_wide=create_wchar_path(path);
142 if (path_wide == (
wchar_t *) NULL)
143 return((FILE *) NULL);
144 mode_wide=create_wchar_path(mode);
145 if (mode_wide == (
wchar_t *) NULL)
148 return((FILE *) NULL);
150 file=_wfopen(path_wide,mode_wide);
159 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 163 directory=getcwd(path,extent);
170 (void) WideCharToMultiByte(CP_UTF8,0,wide_path,-1,path,(
int) extent,NULL,NULL);
174 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__CYGWIN__) && !defined(__MINGW32__) 179 static inline int open_utf8(
const char *path,
int flags,mode_t mode)
181 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 182 return(open(path,flags,mode));
190 path_wide=create_wchar_path(path);
191 if (path_wide == (
wchar_t *) NULL)
193 status=_wopen(path_wide,flags,mode);
199 static inline FILE *
popen_utf8(
const char *command,
const char *type)
201 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 202 return(popen(command,type));
215 length=MultiByteToWideChar(CP_UTF8,0,type,-1,type_wide,5);
218 length=MultiByteToWideChar(CP_UTF8,0,command,-1,NULL,0);
222 if (command_wide == (
wchar_t *) NULL)
224 length=MultiByteToWideChar(CP_UTF8,0,command,-1,command_wide,length);
226 file=_wpopen(command_wide,type_wide);
234 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 235 return(unlink(path));
243 path_wide=create_wchar_path(path);
244 if (path_wide == (
wchar_t *) NULL)
246 status=_wremove(path_wide);
252 static inline int rename_utf8(
const char *source,
const char *destination)
254 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 255 return(rename(source,destination));
264 source_wide=create_wchar_path(source);
265 if (source_wide == (
wchar_t *) NULL)
267 destination_wide=create_wchar_path(destination);
268 if (destination_wide == (
wchar_t *) NULL)
273 status=_wrename(source_wide,destination_wide);
280 static inline int stat_utf8(
const char *path,
struct stat *attributes)
282 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 283 return(stat(path,attributes));
291 path_wide=create_wchar_path(path);
292 if (path_wide == (WCHAR *) NULL)
294 status=wstat(path_wide,attributes);
300 #if defined(__cplusplus) || defined(c_plusplus)
static FILE * popen_utf8(const char *command, const char *type)
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
static void getcwd_utf8(char *path, size_t extent)
static int stat_utf8(const char *path, struct stat *attributes)
MagickPrivate ssize_t GetMagickPageSize(void)
static int remove_utf8(const char *path)
MagickPrivate void ExpandFilename(char *)
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
static FILE * fopen_utf8(const char *path, const char *mode)
struct dirent * readdir(DIR *)
static int open_utf8(const char *path, int flags, mode_t mode)
MagickPrivate MagickBooleanType ShredFile(const char *)
MagickPrivate char ** GetPathComponents(const char *, size_t *)
MagickPrivate char ** ListFiles(const char *, const char *, size_t *)
MagickPrivate MagickBooleanType GetExecutionPath(char *, const size_t)
static int rename_utf8(const char *source, const char *destination)
static int access_utf8(const char *path, int mode)
static int MagickReadDirectory(DIR *directory, struct dirent *entry, struct dirent **result)
MagickExport void * RelinquishMagickMemory(void *memory)
MagickPrivate void ChopPathComponents(char *, const size_t)