From: cristy Date: Fri, 23 Sep 2011 14:40:37 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~6966 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18c6c27bc513a8c73a5bc4a2c157afb19c3e24b9;p=imagemagick --- diff --git a/MagickCore/blob.c b/MagickCore/blob.c index d6923d11e..d5ceec4b7 100644 --- a/MagickCore/blob.c +++ b/MagickCore/blob.c @@ -251,7 +251,7 @@ MagickExport MagickBooleanType BlobToFile(char *filename,const void *blob, if (*filename == '\0') file=AcquireUniqueFileResource(filename); else - file=open(filename,O_RDWR | O_CREAT | O_EXCL | O_BINARY,S_MODE); + file=open_utf8(filename,O_RDWR | O_CREAT | O_EXCL | O_BINARY,S_MODE); if (file == -1) { ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename); @@ -921,7 +921,7 @@ MagickExport unsigned char *FileToBlob(const char *filename,const size_t extent, *length=0; file=fileno(stdin); if (LocaleCompare(filename,"-") != 0) - file=open(filename,O_RDONLY | O_BINARY); + file=open_utf8(filename,O_RDONLY | O_BINARY,0); if (file == -1) { ThrowFileException(exception,BlobError,"UnableToOpenFile",filename); @@ -1110,7 +1110,7 @@ MagickExport MagickBooleanType FileToImage(Image *image,const char *filename) assert(image->signature == MagickSignature); assert(filename != (const char *) NULL); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename); - file=open(filename,O_RDONLY | O_BINARY); + file=open_utf8(filename,O_RDONLY | O_BINARY,0); if (file == -1) { ThrowFileException(&image->exception,BlobError,"UnableToOpenBlob", @@ -1617,7 +1617,7 @@ MagickExport MagickBooleanType ImageToFile(Image *image,char *filename, if (LocaleCompare(filename,"-") == 0) file=fileno(stdout); else - file=open(filename,O_RDWR | O_CREAT | O_EXCL | O_BINARY,S_MODE); + file=open_utf8(filename,O_RDWR | O_CREAT | O_EXCL | O_BINARY,S_MODE); if (file == -1) { ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename); @@ -1926,7 +1926,7 @@ MagickExport MagickBooleanType InjectImageBlob(const ImageInfo *image_info, /* Inject into image stream. */ - file=open(filename,O_RDONLY | O_BINARY); + file=open_utf8(filename,O_RDONLY | O_BINARY,0); if (file == -1) { (void) RelinquishUniqueFileResource(filename); @@ -2391,7 +2391,7 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info, #endif *mode=(*type); mode[1]='\0'; - image->blob->file=(FILE *) popen(filename+1,mode); + image->blob->file=(FILE *) popen_utf8(filename+1,mode); if (image->blob->file == (FILE *) NULL) { ThrowFileException(exception,BlobError,"UnableToOpenBlob",filename); @@ -2406,7 +2406,7 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info, #if defined(S_ISFIFO) if ((status == MagickTrue) && S_ISFIFO(image->blob->properties.st_mode)) { - image->blob->file=(FILE *) OpenMagickStream(filename,type); + image->blob->file=(FILE *) fopen_utf8(filename,type); if (image->blob->file == (FILE *) NULL) { ThrowFileException(exception,BlobError,"UnableToOpenBlob",filename); @@ -2459,7 +2459,7 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info, else if (*type == 'r') { - image->blob->file=(FILE *) OpenMagickStream(filename,type); + image->blob->file=(FILE *) fopen_utf8(filename,type); if (image->blob->file != (FILE *) NULL) { size_t @@ -2567,7 +2567,7 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info, else #endif { - image->blob->file=(FILE *) OpenMagickStream(filename,type); + image->blob->file=(FILE *) fopen_utf8(filename,type); if (image->blob->file != (FILE *) NULL) { image->blob->type=FileStream; diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 2cb73ff50..8f02a6dca 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -642,24 +642,24 @@ static MagickBooleanType OpenPixelCacheOnDisk(CacheInfo *cache_info, { case ReadMode: { - file=open(cache_info->cache_filename,O_RDONLY | O_BINARY); + file=open_utf8(cache_info->cache_filename,O_RDONLY | O_BINARY,0); break; } case WriteMode: { - file=open(cache_info->cache_filename,O_WRONLY | O_CREAT | O_BINARY | - O_EXCL,S_MODE); + file=open_utf8(cache_info->cache_filename,O_WRONLY | O_CREAT | + O_BINARY | O_EXCL,S_MODE); if (file == -1) - file=open(cache_info->cache_filename,O_WRONLY | O_BINARY,S_MODE); + file=open_utf8(cache_info->cache_filename,O_WRONLY | O_BINARY,S_MODE); break; } case IOMode: default: { - file=open(cache_info->cache_filename,O_RDWR | O_CREAT | O_BINARY | + file=open_utf8(cache_info->cache_filename,O_RDWR | O_CREAT | O_BINARY | O_EXCL,S_MODE); if (file == -1) - file=open(cache_info->cache_filename,O_RDWR | O_BINARY,S_MODE); + file=open_utf8(cache_info->cache_filename,O_RDWR | O_BINARY,S_MODE); break; } } diff --git a/MagickCore/delegate.c b/MagickCore/delegate.c index a775a60b9..92f68a45d 100644 --- a/MagickCore/delegate.c +++ b/MagickCore/delegate.c @@ -793,10 +793,10 @@ static MagickBooleanType CopyDelegateFile(const char *source, /* Copy source file to destination. */ - destination_file=open(destination,O_WRONLY | O_BINARY | O_CREAT,S_MODE); + destination_file=open_utf8(destination,O_WRONLY | O_BINARY | O_CREAT,S_MODE); if (destination_file == -1) return(MagickFalse); - source_file=open(source,O_RDONLY | O_BINARY); + source_file=open_utf8(source,O_RDONLY | O_BINARY,0); if (source_file == -1) { (void) close(destination_file); diff --git a/MagickCore/display.c b/MagickCore/display.c index 1837e734a..ac6a95313 100644 --- a/MagickCore/display.c +++ b/MagickCore/display.c @@ -7252,7 +7252,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info, XFileBrowserWidget(display,windows,"Delete",filename); if (*filename == '\0') break; - status=remove(filename) != 0 ? MagickTrue : MagickFalse; + status=remove_utf8(filename) != 0 ? MagickTrue : MagickFalse; if (status != MagickFalse) XNoticeWidget(display,windows,"Unable to delete image file:",filename); break; @@ -13187,7 +13187,7 @@ static Image *XTileImage(Display *display,XResourceInfo *resource_info, status=XConfirmWidget(display,windows,"Really delete tile",filename); if (status <= 0) break; - status=remove(filename) != 0 ? MagickTrue : MagickFalse; + status=remove_utf8(filename) != 0 ? MagickTrue : MagickFalse; if (status != MagickFalse) { XNoticeWidget(display,windows,"Unable to delete image file:", diff --git a/MagickCore/log.c b/MagickCore/log.c index f5f2cb96d..9e259ee1e 100644 --- a/MagickCore/log.c +++ b/MagickCore/log.c @@ -1199,7 +1199,7 @@ MagickBooleanType LogMagickEventList(const LogEventType type,const char *module, return(MagickFalse); } log_info->append=IsPathAccessible(filename); - log_info->file=OpenMagickStream(filename,"ab"); + log_info->file=fopen_utf8(filename,"ab"); filename=(char *) RelinquishMagickMemory(filename); if (log_info->file == (FILE *) NULL) { diff --git a/MagickCore/random.c b/MagickCore/random.c index f518bb193..81f52bc14 100644 --- a/MagickCore/random.c +++ b/MagickCore/random.c @@ -60,6 +60,7 @@ #include "MagickCore/thread_.h" #include "MagickCore/thread-private.h" #include "MagickCore/utility.h" +#include "MagickCore/utility-private.h" /* Define declarations. */ @@ -455,7 +456,7 @@ static StringInfo *GenerateEntropicChaos(RandomInfo *random_info) #endif if (file != -1) (void) close(file); - (void) remove(filename); + (void) remove_utf8(filename); SetStringInfoLength(chaos,strlen(filename)); SetStringInfoDatum(chaos,(unsigned char *) filename); ConcatenateStringInfo(entropy,chaos); @@ -528,7 +529,7 @@ static StringInfo *GenerateEntropicChaos(RandomInfo *random_info) filename=AcquireString("/dev/urandom"); device=StringToStringInfo(filename); device=DestroyStringInfo(device); - file=open(filename,O_RDONLY | O_BINARY); + file=open_utf8(filename,O_RDONLY | O_BINARY,0); filename=DestroyString(filename); if (file != -1) { @@ -546,14 +547,14 @@ static StringInfo *GenerateEntropicChaos(RandomInfo *random_info) filename=AcquireString("/dev/random"); device=StringToStringInfo(filename); device=DestroyStringInfo(device); - file=open(filename,O_RDONLY | O_BINARY); + file=open_utf8(filename,O_RDONLY | O_BINARY,0); filename=DestroyString(filename); if (file == -1) { filename=AcquireString("/dev/srandom"); device=StringToStringInfo(filename); device=DestroyStringInfo(device); - file=open(filename,O_RDONLY | O_BINARY); + file=open_utf8(filename,O_RDONLY | O_BINARY,0); } if (file != -1) { diff --git a/MagickCore/resource.c b/MagickCore/resource.c index 278d7e926..982936ef2 100644 --- a/MagickCore/resource.c +++ b/MagickCore/resource.c @@ -301,7 +301,7 @@ MagickPrivate void AsynchronousResourceComponentTerminus(void) path=(const char *) GetNextKeyInSplayTree(temporary_resources); while (path != (const char *) NULL) { - (void) remove(path); + (void) remove_utf8(path); path=(const char *) GetNextKeyInSplayTree(temporary_resources); } } @@ -333,7 +333,7 @@ MagickPrivate void AsynchronousResourceComponentTerminus(void) static void *DestroyTemporaryResources(void *temporary_resource) { - (void) remove((char *) temporary_resource); + (void) remove_utf8((char *) temporary_resource); temporary_resource=DestroyString((char *) temporary_resource); return((void *) NULL); } @@ -474,7 +474,7 @@ MagickExport int AcquireUniqueFileResource(char *path) *p++=portable_filename[c]; } key=DestroyStringInfo(key); - file=open(path,O_RDWR | O_CREAT | O_EXCL | O_BINARY | O_NOFOLLOW,S_MODE); + file=open_utf8(path,O_RDWR | O_CREAT | O_EXCL | O_BINARY | O_NOFOLLOW,S_MODE); if ((file >= 0) || (errno != EEXIST)) break; } @@ -863,8 +863,8 @@ MagickExport MagickBooleanType RelinquishUniqueFileResource(const char *path) } (void) CopyMagickString(cache_path,path,MaxTextExtent); AppendImageFormat("cache",cache_path); - (void) remove(cache_path); - return(remove(path) == 0 ? MagickTrue : MagickFalse); + (void) remove_utf8(cache_path); + return(remove_utf8(path) == 0 ? MagickTrue : MagickFalse); } /* diff --git a/MagickCore/string.c b/MagickCore/string.c index 4bf2925cd..3cf6d42ca 100644 --- a/MagickCore/string.c +++ b/MagickCore/string.c @@ -52,6 +52,7 @@ #include "MagickCore/resource_.h" #include "MagickCore/signature-private.h" #include "MagickCore/string_.h" +#include "MagickCore/utility-private.h" /* Static declarations. @@ -584,7 +585,7 @@ MagickPrivate StringInfo *ConfigureFileToStringInfo(const char *filename) *map; assert(filename != (const char *) NULL); - file=open(filename,O_RDONLY | O_BINARY); + file=open_utf8(filename,O_RDONLY | O_BINARY,0); if (file == -1) return((StringInfo *) NULL); offset=(MagickOffsetType) lseek(file,0,SEEK_END); diff --git a/MagickCore/utility-private.h b/MagickCore/utility-private.h index 2848fb1ce..5f5886fe0 100644 --- a/MagickCore/utility-private.h +++ b/MagickCore/utility-private.h @@ -125,6 +125,42 @@ static inline int open_utf8(const char *path,int flags,int mode) #endif } +static inline FILE *popen_utf8(const char *command,const char *type) +{ +#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) + return(fopen(command,type)); +#else + FILE + *file; + + int + status; + + WCHAR + *type_wide, + *command_wide; + + command_wide=(WCHAR *) NULL; + count=MultiByteToWideChar(CP_UTF8,0,command,-1,NULL,0); + command_wide=(WCHAR *) AcquireQuantumMemory(count,sizeof(*command_wide)); + if (command_wide == (WCHAR *) NULL) + return(-1); + count=MultiByteToWideChar(CP_UTF8,0,command,-1,command_wide,count); + count=MultiByteToWideChar(CP_UTF8,0,type,-1,NULL,0); + type_wide=(WCHAR *) AcquireQuantumMemory(count,sizeof(*type_wide)); + if (type_wide == (WCHAR *) NULL) + { + command_wide=RelinquishMagickMemory(command_wide); + return(-1); + } + count=MultiByteToWideChar(CP_UTF8,0,type,-1,type_wide,count); + file=_wpopen(path_wide,type_width); + type_wide=RelinquishMagickMemory(type_wide); + path_wide=RelinquishMagickMemory(path_wide); + return(file); +#endif +} + static inline int remove_utf8(const char *path) { #if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__CYGWIN__) || defined(__MINGW32__) diff --git a/MagickCore/utility.c b/MagickCore/utility.c index db38e3498..44594bdf3 100644 --- a/MagickCore/utility.c +++ b/MagickCore/utility.c @@ -200,7 +200,7 @@ MagickExport MagickBooleanType AcquireUniqueSymbolicLink(const char *source, destination_file=AcquireUniqueFileResource(destination); if (destination_file == -1) return(MagickFalse); - source_file=open(source,O_RDONLY | O_BINARY); + source_file=open_utf8(source,O_RDONLY | O_BINARY,0); if (source_file == -1) { (void) close(destination_file); @@ -1106,124 +1106,6 @@ MagickPrivate ssize_t GetMagickPageSize(void) % o attributes: the path attributes are returned here. % */ - -#if defined(MAGICKCORE_HAVE__WFOPEN) -static size_t UTF8ToUTF16(const unsigned char *utf8,wchar_t *utf16) -{ - register const unsigned char - *p; - - if (utf16 != (wchar_t *) NULL) - { - register wchar_t - *q; - - wchar_t - c; - - /* - Convert UTF-8 to UTF-16. - */ - q=utf16; - for (p=utf8; *p != '\0'; p++) - { - if ((*p & 0x80) == 0) - *q=(*p); - else - if ((*p & 0xE0) == 0xC0) - { - c=(*p); - *q=(c & 0x1F) << 6; - p++; - if ((*p & 0xC0) != 0x80) - return(0); - *q|=(*p & 0x3F); - } - else - if ((*p & 0xF0) == 0xE0) - { - c=(*p); - *q=c << 12; - p++; - if ((*p & 0xC0) != 0x80) - return(0); - c=(*p); - *q|=(c & 0x3F) << 6; - p++; - if ((*p & 0xC0) != 0x80) - return(0); - *q|=(*p & 0x3F); - } - else - return(0); - q++; - } - *q++='\0'; - return(q-utf16); - } - /* - Compute UTF-16 string length. - */ - for (p=utf8; *p != '\0'; p++) - { - if ((*p & 0x80) == 0) - ; - else - if ((*p & 0xE0) == 0xC0) - { - p++; - if ((*p & 0xC0) != 0x80) - return(0); - } - else - if ((*p & 0xF0) == 0xE0) - { - p++; - if ((*p & 0xC0) != 0x80) - return(0); - p++; - if ((*p & 0xC0) != 0x80) - return(0); - } - else - return(0); - } - return(p-utf8); -} - -static wchar_t *ConvertUTF8ToUTF16(const unsigned char *source) -{ - size_t - length; - - wchar_t - *utf16; - - length=UTF8ToUTF16(source,(wchar_t *) NULL); - if (length == 0) - { - register ssize_t - i; - - /* - Not UTF-8, just copy. - */ - length=strlen((const char *) source); - utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16)); - if (utf16 == (wchar_t *) NULL) - return((wchar_t *) NULL); - for (i=0; i <= (ssize_t) length; i++) - utf16[i]=source[i]; - return(utf16); - } - utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16)); - if (utf16 == (wchar_t *) NULL) - return((wchar_t *) NULL); - length=UTF8ToUTF16(source,utf16); - return(utf16); -} -#endif - MagickExport MagickBooleanType GetPathAttributes(const char *path, void *attributes) { @@ -1235,21 +1117,8 @@ MagickExport MagickBooleanType GetPathAttributes(const char *path, errno=EINVAL; return(MagickFalse); } -#if !defined(MAGICKCORE_HAVE__WSTAT) - status=stat(path,(struct stat *) attributes) == 0 ? MagickTrue : MagickFalse; -#else - { - wchar_t - *unicode_path; - - unicode_path=ConvertUTF8ToUTF16((const unsigned char *) path); - if (unicode_path == (wchar_t *) NULL) - return(MagickFalse); - status=wstat(unicode_path,(struct stat *) attributes) == 0 ? MagickTrue : - MagickFalse; - unicode_path=(wchar_t *) RelinquishMagickMemory(unicode_path); - } -#endif + status=stat_utf8(path,(struct stat *) attributes) == 0 ? MagickTrue : + MagickFalse; return(status); } @@ -1532,7 +1401,7 @@ MagickExport MagickBooleanType IsPathAccessible(const char *path) return(status); if (S_ISREG(attributes.st_mode) == 0) return(MagickFalse); - if (access(path,F_OK) != 0) + if (access_utf8(path,F_OK) != 0) return(MagickFalse); return(MagickTrue); } @@ -1894,67 +1763,6 @@ MagickExport size_t MultilineCensus(const char *label) % % % % % % -% O p e n M a g i c k S t r e a m % -% % -% % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% OpenMagickStream() opens the file at the specified path and return the -% associated stream. -% -% The path of the OpenMagickStream method is: -% -% FILE *OpenMagickStream(const char *path,const char *mode) -% -% A description of each parameter follows. -% -% o path: the file path. -% -% o mode: the file mode. -% -*/ -MagickExport FILE *OpenMagickStream(const char *path,const char *mode) -{ - FILE - *file; - - if ((path == (const char *) NULL) || (mode == (const char *) NULL)) - { - errno=EINVAL; - return((FILE *) NULL); - } - file=(FILE *) NULL; -#if defined(MAGICKCORE_HAVE__WFOPEN) - { - wchar_t - *unicode_mode, - *unicode_path; - - unicode_path=ConvertUTF8ToUTF16((const unsigned char *) path); - if (unicode_path == (wchar_t *) NULL) - return((FILE *) NULL); - unicode_mode=ConvertUTF8ToUTF16((const unsigned char *) mode); - if (unicode_mode == (wchar_t *) NULL) - { - unicode_path=(wchar_t *) RelinquishMagickMemory(unicode_path); - return((FILE *) NULL); - } - file=_wfopen(unicode_path,unicode_mode); - unicode_mode=(wchar_t *) RelinquishMagickMemory(unicode_mode); - unicode_path=(wchar_t *) RelinquishMagickMemory(unicode_path); - } -#endif - if (file == (FILE *) NULL) - file=fopen(path,mode); - return(file); -} - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % % S y s t e m C o m m a n d % % % % % diff --git a/MagickCore/utility.h b/MagickCore/utility.h index e22a721cc..7b102d8d0 100644 --- a/MagickCore/utility.h +++ b/MagickCore/utility.h @@ -38,9 +38,6 @@ typedef enum extern MagickExport char *Base64Encode(const unsigned char *,const size_t,size_t *); -extern MagickExport FILE - *OpenMagickStream(const char *,const char *); - extern MagickExport int SystemCommand(const MagickBooleanType,const MagickBooleanType,const char *, ExceptionInfo *); diff --git a/MagickWand/convert.c b/MagickWand/convert.c index 8f5c9a974..44655487b 100644 --- a/MagickWand/convert.c +++ b/MagickWand/convert.c @@ -46,6 +46,7 @@ #include "MagickWand/MagickWand.h" #include "MagickWand/mogrify-private.h" #include "MagickCore/string-private.h" +#include "MagickCore/utility-private.h" /* Define declarations. */ @@ -110,7 +111,7 @@ static MagickBooleanType ConcatenateImages(int argc,char **argv, /* Open output file. */ - output=OpenMagickStream(argv[argc-1],"wb"); + output=fopen_utf8(argv[argc-1],"wb"); if (output == (FILE *) NULL) { ThrowFileException(exception,FileOpenError,"UnableToOpenFile", @@ -119,13 +120,13 @@ static MagickBooleanType ConcatenateImages(int argc,char **argv, } for (i=2; i < (ssize_t) (argc-1); i++) { - input=OpenMagickStream(argv[i],"rb"); + input=fopen_utf8(argv[i],"rb"); if (input == (FILE *) NULL) ThrowFileException(exception,FileOpenError,"UnableToOpenFile",argv[i]); for (c=fgetc(input); c != EOF; c=fgetc(input)) (void) fputc((char) c,output); (void) fclose(input); - (void) remove(argv[i]); + (void) remove_utf8(argv[i]); } (void) fclose(output); return(MagickTrue); diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index 5ed3161a8..0167c3790 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -53,6 +53,7 @@ #include "MagickCore/monitor-private.h" #include "MagickCore/thread-private.h" #include "MagickCore/string-private.h" +#include "MagickCore/utility-private.h" /* Constant declaration. @@ -334,7 +335,7 @@ static MagickBooleanType IsPathWritable(const char *path) { if (IsPathAccessible(path) == MagickFalse) return(MagickFalse); - if (access(path,W_OK) != 0) + if (access_utf8(path,W_OK) != 0) return(MagickFalse); return(MagickTrue); } @@ -3744,7 +3745,7 @@ WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, image_info->synchronize=MagickTrue; status&=WriteImages(image_info,image,image->filename,exception); if ((status == MagickFalse) && (*backup_filename != '\0')) - (void) remove(backup_filename); + (void) remove_utf8(backup_filename); RemoveAllImageStack(); continue; } diff --git a/coders/cut.c b/coders/cut.c index 046766b8f..2b7b93474 100644 --- a/coders/cut.c +++ b/coders/cut.c @@ -69,6 +69,7 @@ #include "MagickCore/string_.h" #include "MagickCore/module.h" #include "MagickCore/utility.h" +#include "MagickCore/utility-private.h" typedef struct { @@ -400,14 +401,14 @@ static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception) (void) CopyMagickString(clone_info->filename+i,".PAL",(size_t) (MaxTextExtent-i)); - if((clone_info->file=OpenMagickStream(clone_info->filename,"rb"))==NULL) + if((clone_info->file=fopen_utf8(clone_info->filename,"rb"))==NULL) { (void) CopyMagickString(clone_info->filename+i,".pal",(size_t) (MaxTextExtent-i)); - if((clone_info->file=OpenMagickStream(clone_info->filename,"rb"))==NULL) + if((clone_info->file=fopen_utf8(clone_info->filename,"rb"))==NULL) { clone_info->filename[i]='\0'; - if((clone_info->file=OpenMagickStream(clone_info->filename,"rb"))==NULL) + if((clone_info->file=fopen_utf8(clone_info->filename,"rb"))==NULL) { clone_info=DestroyImageInfo(clone_info); clone_info=NULL; diff --git a/coders/mat.c b/coders/mat.c index 46fcf626d..655599272 100644 --- a/coders/mat.c +++ b/coders/mat.c @@ -74,6 +74,7 @@ #include "MagickCore/string_.h" #include "MagickCore/module.h" #include "MagickCore/transform.h" +#include "MagickCore/utility-private.h" #if defined(MAGICKCORE_ZLIB_DELEGATE) #include "zlib.h" #endif @@ -494,7 +495,7 @@ int status; { fclose(clone_info->file); clone_info->file = NULL; - (void) unlink(clone_info->filename); + (void) remove_utf8(clone_info->filename); } CacheBlock = AcquireQuantumMemory((size_t)((Size<16384)?Size:16384),sizeof(unsigned char *)); @@ -558,7 +559,7 @@ EraseFile: fclose(clone_info->file); clone_info->file = NULL; UnlinkFile: - (void) unlink(clone_info->filename); + (void) remove_utf8(clone_info->filename); return NULL; } @@ -998,7 +999,7 @@ done_reading: { fclose(clone_info->file); clone_info->file = NULL; - (void) unlink(clone_info->filename); + (void) remove_utf8(clone_info->filename); } } } @@ -1054,7 +1055,7 @@ done_reading: { fclose(clone_info->file); clone_info->file = NULL; - (void) unlink(clone_info->filename); + (void) remove_utf8(clone_info->filename); } DestroyImageInfo(clone_info); clone_info = NULL; diff --git a/coders/mpeg.c b/coders/mpeg.c index 1f347685b..be44a923c 100644 --- a/coders/mpeg.c +++ b/coders/mpeg.c @@ -60,6 +60,7 @@ #include "MagickCore/module.h" #include "MagickCore/transform.h" #include "MagickCore/utility.h" +#include "MagickCore/utility-private.h" /* Forward declarations. @@ -417,10 +418,10 @@ static MagickBooleanType CopyDelegateFile(const char *source, /* Copy source file to destination. */ - destination_file=open(destination,O_WRONLY | O_BINARY | O_CREAT,S_MODE); + destination_file=open_utf8(destination,O_WRONLY | O_BINARY | O_CREAT,S_MODE); if (destination_file == -1) return(MagickFalse); - source_file=open(source,O_RDONLY | O_BINARY); + source_file=open_utf8(source,O_RDONLY | O_BINARY,0); if (source_file == -1) { (void) close(destination_file); diff --git a/coders/sfw.c b/coders/sfw.c index 46e6b6b99..9db762bea 100644 --- a/coders/sfw.c +++ b/coders/sfw.c @@ -57,6 +57,7 @@ #include "MagickCore/module.h" #include "MagickCore/transform.h" #include "MagickCore/utility.h" +#include "MagickCore/utility-private.h" /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -301,7 +302,7 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception) file=(FILE *) NULL; unique_file=AcquireUniqueFileResource(read_info->filename); if (unique_file != -1) - file=OpenMagickStream(read_info->filename,"wb"); + file=fopen_utf8(read_info->filename,"wb"); if ((unique_file == -1) || (file == (FILE *) NULL)) { buffer=(unsigned char *) RelinquishMagickMemory(buffer); @@ -325,7 +326,7 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception) char *message; - (void) remove(read_info->filename); + (void) remove_utf8(read_info->filename); read_info=DestroyImageInfo(read_info); message=GetExceptionMessage(errno); (void) ThrowMagickException(&image->exception,GetMagickModule(), diff --git a/coders/wpg.c b/coders/wpg.c index 322702e5f..5fde906dd 100644 --- a/coders/wpg.c +++ b/coders/wpg.c @@ -63,6 +63,7 @@ #include "MagickCore/module.h" #include "MagickCore/transform.h" #include "MagickCore/utility.h" +#include "MagickCore/utility-private.h" typedef struct { @@ -743,7 +744,7 @@ static Image *ExtractPostscript(Image *image,const ImageInfo *image_info, /* Obtain temporary file */ AcquireUniqueFilename(postscript_file); - ps_file=OpenMagickStream(postscript_file,"wb"); + ps_file=fopen_utf8(postscript_file,"wb"); if (ps_file == (FILE *) NULL) goto FINISH;