diff options
Diffstat (limited to 'plugins/FTPFileYM/src/zip/ioapi.c')
-rw-r--r-- | plugins/FTPFileYM/src/zip/ioapi.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/plugins/FTPFileYM/src/zip/ioapi.c b/plugins/FTPFileYM/src/zip/ioapi.c index 49958f61ff..4219ed1f24 100644 --- a/plugins/FTPFileYM/src/zip/ioapi.c +++ b/plugins/FTPFileYM/src/zip/ioapi.c @@ -10,7 +10,7 @@ */ -#if (defined(_WIN32)) +#if (defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)) #define _CRT_SECURE_NO_WARNINGS #endif @@ -22,7 +22,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); else { - return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode); + return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const TCHAR*)filename,mode); } } @@ -32,11 +32,22 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); else { - uLong offsetTruncated = (uLong)offset; - if (offsetTruncated != offset) - return -1; - else - return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); + if (origin == ZLIB_FILEFUNC_SEEK_SET) + { + uLong offsetTruncated = (uLong)offset; + if (offsetTruncated != offset) + return -1; + else + return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); + } + else + { + long offsetTruncated = (long)(__int64)offset; + if (offsetTruncated != (__int64)offset) + return -1; + else + return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); + } } } @@ -72,7 +83,7 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef -static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); +static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const TCHAR* filename, int mode)); static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); @@ -80,39 +91,39 @@ static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPO static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); -static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) +static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const TCHAR* filename, int mode) { FILE* file = NULL; - const char* mode_fopen = NULL; + const TCHAR* mode_fopen = NULL; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - mode_fopen = "rb"; + mode_fopen = _T("rb"); else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; + mode_fopen = _T("r+b"); else if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; + mode_fopen = _T("wb"); if ((filename!=NULL) && (mode_fopen != NULL)) - file = fopen(filename, mode_fopen); + file = _tfopen(filename, mode_fopen); return file; } static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) { FILE* file = NULL; - const char* mode_fopen = NULL; + const TCHAR* mode_fopen = NULL; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - mode_fopen = "rb"; + mode_fopen = _T("rb"); else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; + mode_fopen = _T("r+b"); else if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; + mode_fopen = _T("wb"); if ((filename!=NULL) && (mode_fopen != NULL)) - file = fopen64((const char*)filename, mode_fopen); + file = _tfopen((const TCHAR*)filename, mode_fopen); return file; } @@ -188,7 +199,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T } ret = 0; - if(fseeko64((FILE *)stream, offset, fseek_origin) != 0) + if (fseeko64((FILE *)stream, offset, fseek_origin) != 0) ret = -1; return ret; |