18 #ifndef _MAGICKCORE_UTILITY_PRIVATE_H
19 #define _MAGICKCORE_UTILITY_PRIVATE_H
21 #if defined(__cplusplus) || defined(c_plusplus)
37 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
38 return(access(path,mode));
47 path_wide=(WCHAR *) NULL;
48 count=MultiByteToWideChar(CP_UTF8,0,path,-1,NULL,0);
50 if (path_wide == (WCHAR *) NULL)
52 count=MultiByteToWideChar(CP_UTF8,0,path,-1,path_wide,count);
53 status=_waccess(path_wide,mode);
61 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
62 return(fopen(path,mode));
74 path_wide=(WCHAR *) NULL;
75 count=MultiByteToWideChar(CP_UTF8,0,path,-1,NULL,0);
77 if (path_wide == (WCHAR *) NULL)
78 return((FILE *) NULL);
79 count=MultiByteToWideChar(CP_UTF8,0,path,-1,path_wide,count);
80 count=MultiByteToWideChar(CP_UTF8,0,mode,-1,NULL,0);
82 if (mode_wide == (WCHAR *) NULL)
85 return((FILE *) NULL);
87 count=MultiByteToWideChar(CP_UTF8,0,mode,-1,mode_wide,count);
88 file=_wfopen(path_wide,mode_wide);
95 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__)
102 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
103 return(open(path,flags,mode));
112 path_wide=(WCHAR *) NULL;
113 count=MultiByteToWideChar(CP_UTF8,0,path,-1,NULL,0);
115 if (path_wide == (WCHAR *) NULL)
117 count=MultiByteToWideChar(CP_UTF8,0,path,-1,path_wide,count);
118 status=_wopen(path_wide,flags,mode);
124 static inline FILE *
popen_utf8(
const char *command,
const char *type)
126 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
127 return(popen(command,type));
139 command_wide=(WCHAR *) NULL;
140 count=MultiByteToWideChar(CP_UTF8,0,command,-1,NULL,0);
142 if (command_wide == (WCHAR *) NULL)
143 return((FILE *) NULL);
144 count=MultiByteToWideChar(CP_UTF8,0,command,-1,command_wide,count);
145 count=MultiByteToWideChar(CP_UTF8,0,type,-1,NULL,0);
147 if (type_wide == (WCHAR *) NULL)
150 return((FILE *) NULL);
152 count=MultiByteToWideChar(CP_UTF8,0,type,-1,type_wide,count);
153 file=_wpopen(command_wide,type_wide);
162 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
163 return(unlink(path));
172 path_wide=(WCHAR *) NULL;
173 count=MultiByteToWideChar(CP_UTF8,0,path,-1,NULL,0);
175 if (path_wide == (WCHAR *) NULL)
177 count=MultiByteToWideChar(CP_UTF8,0,path,-1,path_wide,count);
178 status=_wremove(path_wide);
184 static inline int rename_utf8(
const char *source,
const char *destination)
186 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
187 return(rename(source,destination));
197 source_wide=(WCHAR *) NULL;
198 count=MultiByteToWideChar(CP_UTF8,0,source,-1,NULL,0);
200 if (source_wide == (WCHAR *) NULL)
202 count=MultiByteToWideChar(CP_UTF8,0,source,-1,source_wide,count);
203 count=MultiByteToWideChar(CP_UTF8,0,destination,-1,NULL,0);
205 sizeof(*destination_wide));
206 if (destination_wide == (WCHAR *) NULL)
211 count=MultiByteToWideChar(CP_UTF8,0,destination,-1,destination_wide,count);
212 status=_wrename(source_wide,destination_wide);
221 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
222 return(stat(path,attributes));
231 path_wide=(WCHAR *) NULL;
232 count=MultiByteToWideChar(CP_UTF8,0,path,-1,NULL,0);
234 if (path_wide == (WCHAR *) NULL)
236 count=MultiByteToWideChar(CP_UTF8,0,path,-1,path_wide,count);
237 status=_wstat64(path_wide,attributes);
243 #if defined(__cplusplus) || defined(c_plusplus)