diff --git a/CImg.h b/CImg.h index d19b61e3089f757832f3cb6a875b530276d7f4f3..bff229cce6ca56e28056a58bf03e71818185d121 100644 --- a/CImg.h +++ b/CImg.h @@ -6281,7 +6281,7 @@ namespace cimg_library_suffixed { \return File size or '-1' if file does not exist. **/ inline cimg_int64 fsize(const char *const filename) { - std::FILE *const file = std::fopen(filename,"rb"); + std::FILE *const file = std_fopen(filename,"rb"); if (!file) return (cimg_int64)-1; std::fseek(file,0,SEEK_END); const cimg_int64 siz = (cimg_int64)std::ftell(file); @@ -59818,20 +59818,21 @@ namespace cimg { #if cimg_OS==2 // Convert 'path' to a wide-character string. int err = MultiByteToWideChar(CP_UTF8,0,path,-1,0,0); - if (!err) return std_fopen(path,mode); + if (!err) return std::fopen(path,mode); CImg<wchar_t> wpath(err); err = MultiByteToWideChar(CP_UTF8,0,path,-1,wpath,err); - if (!err) return std_fopen(path,mode); + if (!err) return std::fopen(path,mode); // Convert 'mode' to a wide-character string. err = MultiByteToWideChar(CP_UTF8,0,mode,-1,0,0); if (!err) return std_fopen(path,mode); CImg<wchar_t> wmode(err); err = MultiByteToWideChar(CP_UTF8,0,mode,-1,wmode,err); - if (!err) return std_fopen(path,mode); - return _wfopen(wpath,wmode); + if (!err) return std::fopen(path,mode); + std::FILE *const res = _wfopen(wpath,wmode); + return res?res:std::fopen(path,mode); #else - return std_fopen(path,mode); + return std::fopen(path,mode); #endif }