123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- /* iowin32.c -- IO base function header for compress/uncompress .zip
- Version 1.1, February 14h, 2010
- part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
- Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
- Modifications for Zip64 support
- Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read MiniZip_info.txt
- */
- #include "stdafx.h"
- #include "io_mfc_mem.h"
- #include <afx.h>
- #ifndef INVALID_HANDLE_VALUE
- #define INVALID_HANDLE_VALUE (0xFFFFFFFF)
- #endif
- #ifndef INVALID_SET_FILE_POINTER
- #define INVALID_SET_FILE_POINTER ((DWORD)-1)
- #endif
- voidpf ZCALLBACK mfc_mem_open_file_func OF((voidpf opaque, const char* filename, int mode));
- uLong ZCALLBACK mfc_mem_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
- uLong ZCALLBACK mfc_mem_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
- long ZCALLBACK mfc_mem_tell_file_func OF((voidpf opaque, voidpf stream));
- long ZCALLBACK mfc_mem_seek_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
- int ZCALLBACK mfc_mem_close_file_func OF((voidpf opaque, voidpf stream));
- int ZCALLBACK mfc_mem_error_file_func OF((voidpf opaque, voidpf stream));
- voidpf ZCALLBACK mfc_mem_open_file_func (voidpf opaque,const char* filename,int mode)
- {
- CMemFile* mem_file=NULL;
- if(opaque){
- mem_file = (CMemFile*)opaque;
- }
- return mem_file;
- }
- uLong ZCALLBACK mfc_mem_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
- {
- uLong ret=0;
- CMemFile* mem_file=NULL;
- if(stream!=NULL)
- mem_file=( CMemFile* )stream;
- if(mem_file!=NULL){
- if(ret =mem_file->Read(buf,size)){
- }
- }
- return ret;
- }
- uLong ZCALLBACK mfc_mem_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
- {
- uLong ret=0;
- CMemFile* mem_file=NULL;
- if(stream!=NULL)
- mem_file=( CMemFile* )stream;
- if(mem_file!=NULL){
- mem_file->Write(buf,size);
- ret = size;
-
- }
- return ret;
- }
- long ZCALLBACK mfc_mem_tell_file_func (voidpf opaque,voidpf stream)
- {
- long ret=-1;
- HANDLE hFile = NULL;
- CMemFile* mem_file=NULL;
- if(stream!=NULL)
- mem_file=( CMemFile* )stream;
- if(mem_file!=NULL){
- ret=mem_file->GetPosition();
- }
- return ret;
- }
- long ZCALLBACK mfc_mem_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
- {
- DWORD dwMoveMethod=0xFFFFFFFF;
- long ret=-1;
- CMemFile* mem_file=NULL;
- if(stream!=NULL)
- mem_file=( CMemFile* )stream;
- switch (origin)
- {
- case ZLIB_FILEFUNC_SEEK_CUR :
- dwMoveMethod = FILE_CURRENT;
- break;
- case ZLIB_FILEFUNC_SEEK_END :
- dwMoveMethod = FILE_END;
- break;
- case ZLIB_FILEFUNC_SEEK_SET :
- dwMoveMethod = FILE_BEGIN;
- break;
- default: return -1;
- }
- if(mem_file!=NULL){
- mem_file->Seek(offset,origin);
- ret =0;
- }
- return ret;
- }
- int ZCALLBACK mfc_mem_close_file_func (voidpf opaque, voidpf stream)
- {
- int ret=-1;
- CMemFile* mem_file=NULL;
- if(stream!=NULL)
- mem_file=( CMemFile* )stream;
- if(mem_file!=NULL){
- //mem_file->Close();
- ret=0;
- }
- return ret;
- }
- int ZCALLBACK mfc_mem_error_file_func (voidpf opaque,voidpf stream)
- {
- int ret=-1;
- CMemFile* mem_file=NULL;
- if(stream!=NULL){
- mem_file=( CMemFile* )stream;
- ret =0;
- }
- return ret;
- }
- void fill_mfc_mem_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
- {
- pzlib_filefunc_def->zopen_file = mfc_mem_open_file_func;
- pzlib_filefunc_def->zread_file = mfc_mem_read_file_func;
- pzlib_filefunc_def->zwrite_file = mfc_mem_write_file_func;
- pzlib_filefunc_def->ztell_file = mfc_mem_tell_file_func;
- pzlib_filefunc_def->zseek_file = mfc_mem_seek_file_func;
- pzlib_filefunc_def->zclose_file = mfc_mem_close_file_func;
- pzlib_filefunc_def->zerror_file = mfc_mem_error_file_func;
- pzlib_filefunc_def->opaque = NULL;
- }
|