18 #ifndef MAGICKCORE_UTILITY_PRIVATE_H 19 #define MAGICKCORE_UTILITY_PRIVATE_H 21 #include "magick/memory_.h" 22 #include "magick/nt-base.h" 23 #include "magick/nt-base-private.h" 24 #if defined(MAGICKCORE_HAVE_UTIME_H) 27 #if defined(__MINGW32__) 31 #if defined(__cplusplus) || defined(c_plusplus) 35 extern MagickPrivate MagickBooleanType
36 ShredFile(
const char *);
38 static inline int MagickReadDirectory(
DIR *directory,
struct dirent *entry,
43 *result=readdir(directory);
47 static inline int access_utf8(
const char *path,
int mode)
49 if (path == (
const char *) NULL)
51 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 52 return(access(path,mode));
54 return(NTAccessWide(path,mode));
58 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__CYGWIN__) 59 #define close_utf8 _close 61 #define close_utf8 close 64 static inline FILE *fopen_utf8(
const char *path,
const char *mode)
66 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 67 return(fopen(path,mode));
69 return(NTOpenFileWide(path,mode));
73 static inline MagickBooleanType is_symlink_utf8(
const char *path)
75 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 76 #if defined(MAGICKCORE_POSIX_SUPPORT) 80 if (lstat(path,&status) == -1)
82 return(S_ISLNK(status.st_mode) != 0 ? MagickTrue : MagickFalse);
87 return(NTIsSymlinkWide(path));
91 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__CYGWIN__) && !defined(__MINGW32__) 96 static inline int open_utf8(
const char *path,
int flags,mode_t mode)
98 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 99 return(open(path,flags,mode));
101 return(NTOpenWide(path,flags,mode));
105 static inline FILE *popen_utf8(
const char *command,
const char *type)
107 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 108 return(popen(command,type));
110 return(NTOpenPipeWide(command,type));
114 static inline char *realpath_utf8(
const char *path)
116 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 117 #if defined(MAGICKCORE_HAVE_REALPATH) 122 return(realpath(path,(
char *) NULL));
124 return(AcquireString(path));
127 return(NTRealPathWide(path));
131 static inline int remove_utf8(
const char *path)
133 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 134 return(unlink(path));
136 return(NTRemoveWide(path));
140 static inline int rename_utf8(
const char *source,
const char *destination)
142 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 143 return(rename(source,destination));
145 return(NTRenameWide(source,destination));
149 static inline int set_file_timestamp(
const char *path,
struct stat *attributes)
154 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 155 #if defined(MAGICKCORE_HAVE_UTIMENSAT) 156 #if defined(__APPLE__) || defined(__NetBSD__) 157 #define st_atim st_atimespec 158 #define st_ctim st_ctimespec 159 #define st_mtim st_mtimespec 165 timestamp[0].tv_sec=attributes->st_atim.tv_sec;
166 timestamp[0].tv_nsec=attributes->st_atim.tv_nsec;
167 timestamp[1].tv_sec=attributes->st_mtim.tv_sec;
168 timestamp[1].tv_nsec=attributes->st_mtim.tv_nsec;
169 status=utimensat(AT_FDCWD,path,timestamp,0);
174 timestamp.actime=attributes->st_atime;
175 timestamp.modtime=attributes->st_mtime;
176 status=utime(path,×tamp);
179 status=NTSetFileTimestamp(path,attributes);
184 static inline int stat_utf8(
const char *path,
struct stat *attributes)
186 #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) 187 return(stat(path,attributes));
189 return(NTStatWide(path,attributes));
193 #if defined(__cplusplus) || defined(c_plusplus)