亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? unzipfile.cpp

?? 利用ZIP庫進行壓縮和解壓縮
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// UnzipFile.cpp: implementation of the CUnzipFile class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "UnzipFile.h"

#define SIZECENTRALDIRITEM (0x2e)
#define SIZEZIPLOCALHEADER (0x1e)


#ifndef UNZ_BUFSIZE
#define UNZ_BUFSIZE (16384)
#endif

#ifndef UNZ_MAXFILENAMEINZIP
#define UNZ_MAXFILENAMEINZIP (256)
#endif

#define BUFREADCOMMENT (0x400)


#define UNZ_PARAMERROR                  (-102)
#define UNZ_BADZIPFILE                  (-103)
#define UNZ_CRCERROR                    (-105)

unz_s::unz_s()
{
	pfile_in_zip_read = NULL;
}

void unz_s::alloc_pfile_in_zip_read()
{
	if (!pfile_in_zip_read)
		pfile_in_zip_read = new file_in_zip_read_info;
}

void unz_s::free_pfile_in_zip_read()
{
	if (pfile_in_zip_read)
	{
		delete pfile_in_zip_read;
		pfile_in_zip_read = NULL;
	}

}

unz_s::~unz_s()
{
	free_pfile_in_zip_read();
}

file_in_zip_read_info::file_in_zip_read_info()
{
	read_buffer = new char[UNZ_BUFSIZE];
	stream_initialised  = 0;
	pos_local_extrafield = 0;
	crc32 = 0;
	stream.total_out = 0;
}


file_in_zip_read_info::~file_in_zip_read_info()
{
	delete[] read_buffer;
}


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CUnzipFile::CUnzipFile()
{
	m_bZipFile = false;
	m_pFile = &uf.file;
}


CUnzipFile::CUnzipFile(LPCTSTR lpszPath)
{
	m_bZipFile = false;
	m_pFile = &uf.file;
	Open(lpszPath);
}

//   Close a ZipFile
void CUnzipFile::Close()
{
	if (IsClosed())
		return;

    if (uf.pfile_in_zip_read)
        CloseCurrentFile();
	
	uf.file.Close();
}

//   Close the file in zip opened with OpenCurrentFile
void CUnzipFile::CloseCurrentFile()
{

	if (uf.pfile_in_zip_read == NULL)
		return; // already closed - do not throw an exception

	if (uf.pfile_in_zip_read->rest_read_uncompressed == 0)
	{
		if (uf.pfile_in_zip_read->crc32 != uf.pfile_in_zip_read->crc32_wait)
			ThrowError(UNZ_CRCERROR);
	}

	
	if (uf.pfile_in_zip_read->stream_initialised)
		inflateEnd(&uf.pfile_in_zip_read->stream);

	uf.free_pfile_in_zip_read();

}

/*
  Set the current file of the zipfile to the first file.
*/
void CUnzipFile::GoToFirstFile()
{
	uf.pos_in_central_dir = uf.offset_central_dir;
	uf.num_file = 0;
	unzlocal_GetCurrentFileInfoInternal(uf.cur_file_info,
										uf.cur_file_info_internal,
										NULL,0,NULL,0,NULL,0);
	uf.current_file_ok = 1;
}


/*
  Try locate the file szFileName in the zipfile.

  return value :
  true if the file is found. It becomes the current file.
  false if the file is not found
*/
bool CUnzipFile::LocateFile(CString szFileName, bool bCaseSensitive)
{

    if (szFileName.GetLength() >= UNZ_MAXFILENAMEINZIP)
        ThrowError(UNZ_PARAMERROR);

	if (!uf.current_file_ok)
		return false;

	uLong num_fileSaved = uf.num_file;
	uLong pos_in_central_dirSaved = uf.pos_in_central_dir;

	GoToFirstFile();

	bool res = true;
	while (res)
	{
		char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
		GetCurrentFileInfo(NULL, szCurrentFileName, sizeof(szCurrentFileName)-1,
								NULL,0,NULL,0);
		if (StringFileNameCompare(szCurrentFileName, szFileName, bCaseSensitive)==0)
			return true;

		res = GoToNextFile();
	}

	uf.num_file = num_fileSaved ;
	uf.pos_in_central_dir = pos_in_central_dirSaved ;

	return false;
}



/*
  Set the current file of the zipfile to the next file.
  return true if there is no problem
  return false if the actual file was the latest.
*/
bool CUnzipFile::GoToNextFile()
{
	if (!uf.current_file_ok)
		return false;

	if (uf.num_file + 1 == uf.gi.number_entry)
		return false;

	uf.pos_in_central_dir += SIZECENTRALDIRITEM + uf.cur_file_info.size_filename +
			uf.cur_file_info.size_file_extra + uf.cur_file_info.size_file_comment ;

	uf.num_file++;
	unzlocal_GetCurrentFileInfoInternal(uf.cur_file_info,
										uf.cur_file_info_internal,
										NULL,0,NULL,0,NULL,0);
	uf.current_file_ok = 1;
	return true;
}

/*
  Read the local header of the current zipfile
  Check the coherency of the local header and info in the end of central
        directory about this file
  store in *piSizeVar the size of extra info in local header
        (filename and size of extra field data)
*/
void CUnzipFile::unzlocal_CheckCurrentFileCoherencyHeader (uInt & iSizeVar,
													uLong & offset_local_extrafield,
													uLong & size_local_extrafield)
{

	iSizeVar = 0;
	offset_local_extrafield = 0;
	size_local_extrafield = 0;

	uf.file.Seek(uf.cur_file_info_internal.offset_curfile + uf.byte_before_the_zipfile, CFile::begin);

	uLong uMagic;
	unzlocal_getLong(uMagic);
	if (uMagic!=0x04034b50)
		ThrowError(UNZ_BADZIPFILE);

	uLong uData;
	unzlocal_getShort(uData);

// 	if (uData != uf.cur_file_info.version)
// 		ThrowError(UNZ_BADZIPFILE);

	uLong uFlags;
	unzlocal_getShort(uFlags);

	unzlocal_getShort(uData);
	if (uData != uf.cur_file_info.compression_method)
		ThrowError(UNZ_BADZIPFILE);

    if ((uf.cur_file_info.compression_method != 0) &&
                         (uf.cur_file_info.compression_method != Z_DEFLATED))
        ThrowError(UNZ_BADZIPFILE);

	unzlocal_getLong(uData); /* date/time */

	unzlocal_getLong(uData); /* crc */
	if ((uData != uf.cur_file_info.crc) &&
		                      ((uFlags & 8)==0))
		ThrowError(UNZ_BADZIPFILE);

	unzlocal_getLong(uData); /* size compr */

	if ((uData != uf.cur_file_info.compressed_size) &&
							  ((uFlags & 8) == 0))
		ThrowError(UNZ_BADZIPFILE);

	unzlocal_getLong(uData); /* size uncompr */

	if ((uData!=uf.cur_file_info.uncompressed_size) && 
							  ((uFlags & 8)==0))
		ThrowError(UNZ_BADZIPFILE);

	uLong size_filename;
	unzlocal_getShort(size_filename);

	if ((size_filename != uf.cur_file_info.size_filename))
		ThrowError(UNZ_BADZIPFILE);

	iSizeVar = (uInt)size_filename;

	uLong size_extra_field;
	unzlocal_getShort(size_extra_field);

	offset_local_extrafield = uf.cur_file_info_internal.offset_curfile +
									SIZEZIPLOCALHEADER + size_filename;
	size_local_extrafield = (uInt)size_extra_field;

	iSizeVar += (uInt)size_extra_field;

}


//   Open for reading data the current file in the zipfile.
void CUnzipFile::OpenCurrentFile()
{

	ASSERT(uf.current_file_ok);

	if (!uf.current_file_ok)
		ThrowError(UNZ_PARAMERROR);

    if (uf.pfile_in_zip_read)
        CloseCurrentFile();

	uInt iSizeVar;
	uLong offset_local_extrafield;  /* offset of the local extra field */
	uLong  size_local_extrafield;    /* size of the local extra field */

	unzlocal_CheckCurrentFileCoherencyHeader(iSizeVar,
				offset_local_extrafield, size_local_extrafield);

	uf.alloc_pfile_in_zip_read();


	uf.pfile_in_zip_read->offset_local_extrafield = offset_local_extrafield;
	uf.pfile_in_zip_read->size_local_extrafield = size_local_extrafield;

	
	if ((uf.cur_file_info.compression_method!=0) &&
        (uf.cur_file_info.compression_method!=Z_DEFLATED))
		ThrowError(UNZ_BADZIPFILE);


	uf.pfile_in_zip_read->crc32_wait = uf.cur_file_info.crc;
	uf.pfile_in_zip_read->compression_method =
            uf.cur_file_info.compression_method;
	
	uf.pfile_in_zip_read->byte_before_the_zipfile=uf.byte_before_the_zipfile;


	if (uf.cur_file_info.compression_method != 0)
	{
	  uf.pfile_in_zip_read->stream.zalloc = (alloc_func)myalloc;
	  uf.pfile_in_zip_read->stream.zfree = (free_func)myfree;
	  uf.pfile_in_zip_read->stream.opaque = m_bDetectZlibMemoryLeaks ? &m_list : 0;
      
	  int err = inflateInit2(&uf.pfile_in_zip_read->stream, -MAX_WBITS);

	  if (err == Z_OK)
	    uf.pfile_in_zip_read->stream_initialised=1;
	  else 
		  CheckForError(err);
        /* windowBits is passed < 0 to tell that there is no zlib header.
         * Note that in this case inflate *requires* an extra "dummy" byte
         * after the compressed stream in order to complete decompression and
         * return Z_STREAM_END. 
         * In unzip, i don't wait absolutely Z_STREAM_END because I known the 
         * size of both compressed and uncompressed data
         */
	}
	uf.pfile_in_zip_read->rest_read_compressed = 
            uf.cur_file_info.compressed_size ;
	uf.pfile_in_zip_read->rest_read_uncompressed = 
            uf.cur_file_info.uncompressed_size ;

	
	uf.pfile_in_zip_read->pos_in_zipfile = 
            uf.cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + 
			  iSizeVar;
	
	uf.pfile_in_zip_read->stream.avail_in = (uInt)0;

}
/*
  Write info about the ZipFile in the *pglobal_info structure.
  No preparation of the structure is needed
*/
void CUnzipFile::GetGlobalInfo(unz_global_info &global_info)
{
	global_info = uf.gi;
}

void CUnzipFile::GetCurrentFileInfo ( unz_file_info* file_info,
                                         LPSTR szFileName,
										 uLong fileNameBufferSize,
										 void *extraField,
										 uLong extraFieldBufferSize,
										 LPSTR szComment,
										 uLong commentBufferSize)
{

	
	unz_file_info temp;
	if (!file_info)
		file_info = &temp;

	unz_file_info_internal temp1;
	unzlocal_GetCurrentFileInfoInternal(*file_info, temp1, szFileName, fileNameBufferSize,
		extraField, extraFieldBufferSize, szComment, commentBufferSize);
}



/*
  Read bytes from the current file.
  buf contain buffer where data must be copied
  len the size of buf.

  return the number of byte copied if somes bytes are copied
  return 0 if the end of file was reached
*/
int CUnzipFile::ReadCurrentFile(void* buf, UINT len)
{

	if (!uf.pfile_in_zip_read)
		ThrowError(UNZ_PARAMERROR);

	if ((len == 0) || !buf)
		return 0;

	uf.pfile_in_zip_read->stream.next_out = (Bytef*)buf;
	uf.pfile_in_zip_read->stream.avail_out = (uInt)len;
	
	if (len > uf.pfile_in_zip_read->rest_read_uncompressed)
		uf.pfile_in_zip_read->stream.avail_out = 
		  (uInt)uf.pfile_in_zip_read->rest_read_uncompressed;


	uInt iRead = 0;

	while (uf.pfile_in_zip_read->stream.avail_out>0)
	{
		if ((uf.pfile_in_zip_read->stream.avail_in==0) &&
            (uf.pfile_in_zip_read->rest_read_compressed>0))
		{
			uInt uReadThis = UNZ_BUFSIZE;
			if (uf.pfile_in_zip_read->rest_read_compressed<uReadThis)
				uReadThis = (uInt)uf.pfile_in_zip_read->rest_read_compressed;
			if (uReadThis == 0)
				return 0;


			uf.file.Seek(uf.pfile_in_zip_read->pos_in_zipfile + 
				uf.pfile_in_zip_read->byte_before_the_zipfile, CFile::begin);

			uf.file.Read(uf.pfile_in_zip_read->read_buffer, uReadThis);
			uf.pfile_in_zip_read->pos_in_zipfile += uReadThis;

			uf.pfile_in_zip_read->rest_read_compressed-=uReadThis;
			
			uf.pfile_in_zip_read->stream.next_in = 
                (Bytef*)uf.pfile_in_zip_read->read_buffer;
			uf.pfile_in_zip_read->stream.avail_in = (uInt)uReadThis;
		}

		if (uf.pfile_in_zip_read->compression_method==0)
		{
			uInt uDoCopy;
			if (uf.pfile_in_zip_read->stream.avail_out < 
                            uf.pfile_in_zip_read->stream.avail_in)
				uDoCopy = uf.pfile_in_zip_read->stream.avail_out ;
			else
				uDoCopy = uf.pfile_in_zip_read->stream.avail_in ;

			memcpy(uf.pfile_in_zip_read->stream.next_out, 
				uf.pfile_in_zip_read->stream.next_in, uDoCopy);
					
			uf.pfile_in_zip_read->crc32 = crc32(uf.pfile_in_zip_read->crc32,
								uf.pfile_in_zip_read->stream.next_out,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91影视在线播放| 精彩视频一区二区三区| 国产一二三精品| 日韩午夜在线影院| 青青草成人在线观看| 日韩久久精品一区| 国产一区二区三区在线观看免费视频| 久久精品夜夜夜夜久久| 成人黄色777网| 亚洲超碰精品一区二区| 26uuu亚洲婷婷狠狠天堂| 成人性色生活片免费看爆迷你毛片| 国产精品乱人伦中文| 在线视频国内自拍亚洲视频| 日本aⅴ免费视频一区二区三区 | 色哟哟欧美精品| 精品国产乱码久久久久久久| 国产精品白丝av| 亚洲视频一二三| 欧美日韩一级片网站| 国产一区二区在线看| 最新高清无码专区| 欧美久久久久久久久中文字幕| 国产米奇在线777精品观看| 亚洲色图视频网站| 日韩一级视频免费观看在线| 国产高清精品网站| 亚洲一区二区在线观看视频| 精品日本一线二线三线不卡| av亚洲精华国产精华| 午夜精品久久一牛影视| 久久久精品天堂| 欧美日韩国产123区| 国产一区二区视频在线| 综合亚洲深深色噜噜狠狠网站| 久久久不卡网国产精品一区| 99re这里只有精品视频首页| 亚洲成人精品影院| 亚洲国产成人私人影院tom| 欧美日韩综合在线免费观看| 国产不卡视频一区二区三区| 亚洲一区精品在线| 中文天堂在线一区| 欧美一级夜夜爽| 91日韩一区二区三区| 韩国三级电影一区二区| 午夜欧美一区二区三区在线播放| 国产精品色婷婷久久58| 日韩视频123| 欧美日韩一级二级| 91亚洲资源网| 成人永久看片免费视频天堂| 九一久久久久久| 日本一区中文字幕| 亚洲一区自拍偷拍| 自拍偷拍欧美精品| 国产亚洲欧洲一区高清在线观看| 欧美妇女性影城| 成人午夜激情视频| 韩国av一区二区三区在线观看| 亚洲va欧美va天堂v国产综合| 国产精品成人免费| 国产亚洲综合色| 欧美大度的电影原声| 欧美日韩一区二区在线视频| a在线欧美一区| 成人黄色电影在线| 成人性色生活片| 成人免费视频视频| 国产a精品视频| 大胆亚洲人体视频| 成人ar影院免费观看视频| 国产999精品久久| 成人综合激情网| 97se狠狠狠综合亚洲狠狠| 成人视屏免费看| aa级大片欧美| www.性欧美| 日本韩国精品在线| 欧美性色欧美a在线播放| 色乱码一区二区三区88| 色噜噜夜夜夜综合网| 欧美日韩一区在线| 国产一区二区三区电影在线观看| 一区二区三区在线免费观看| 亚洲欧美电影院| 亚洲人午夜精品天堂一二香蕉| 中文字幕亚洲精品在线观看| 亚洲丝袜另类动漫二区| 亚洲综合在线电影| 五月天激情小说综合| 美女mm1313爽爽久久久蜜臀| 精品一区二区三区免费观看| 国产一区二区三区久久久| 风流少妇一区二区| 99精品视频免费在线观看| 91久久精品一区二区三| 欧美精品久久99| 精品国产91亚洲一区二区三区婷婷| 久久一夜天堂av一区二区三区| 国产农村妇女精品| 亚洲激情图片qvod| 美国十次综合导航| 成人av在线播放网址| 在线视频一区二区免费| 91精品国产综合久久精品| www一区二区| 综合自拍亚洲综合图不卡区| 国产精品国产三级国产aⅴ无密码| 日本中文在线一区| 国产一区日韩二区欧美三区| 成人午夜视频福利| 精品视频在线看| 久久精品人人做人人爽人人| 一区二区三区免费在线观看| 久久国产尿小便嘘嘘尿| 99久久久国产精品| 日韩欧美国产一区二区三区 | 一个色妞综合视频在线观看| 麻豆成人在线观看| 99精品偷自拍| 欧美一级淫片007| 亚洲女与黑人做爰| 国产一区91精品张津瑜| 欧美日韩一区二区在线观看| 久久久精品免费网站| 亚洲福利电影网| 9久草视频在线视频精品| 欧美xxxxx裸体时装秀| 一区二区不卡在线播放| 国产成人精品亚洲777人妖| 欧美日韩国产综合草草| 亚洲欧洲成人自拍| 久久综合九色综合久久久精品综合 | 欧洲人成人精品| 久久久久久久久久电影| 日韩av不卡在线观看| 欧洲色大大久久| 国产精品久久夜| 国产麻豆91精品| 日韩一区二区在线播放| 亚洲一区在线看| 99re热视频这里只精品| 国产日韩欧美精品综合| 日本欧美加勒比视频| 欧美视频一区在线| 一区二区三区四区中文字幕| 成人一级黄色片| 久久久99免费| 久久99蜜桃精品| 91麻豆精品国产91久久久使用方法 | 国产中文字幕精品| 日韩一区二区三区四区五区六区| 一区二区三区成人| 色av成人天堂桃色av| 亚洲免费观看高清完整版在线| 成人高清在线视频| 午夜精品一区二区三区电影天堂| 成人免费观看男女羞羞视频| 欧美精品一区二区三区在线播放| 婷婷久久综合九色综合伊人色| 欧洲人成人精品| 一区二区三区av电影| 91黄视频在线| 一区二区三区免费观看| 欧洲精品视频在线观看| 亚洲精品视频一区| 一本久久综合亚洲鲁鲁五月天| 综合中文字幕亚洲| 欧美最猛黑人xxxxx猛交| 一区二区成人在线| 欧美高清激情brazzers| 日本三级亚洲精品| 精品剧情v国产在线观看在线| 国产一区二区调教| 26uuu国产日韩综合| 国产传媒一区在线| 中文字幕亚洲一区二区av在线| 91在线视频观看| 一区二区三区高清不卡| 欧美日韩国产一级片| 日韩黄色免费电影| 日韩视频在线一区二区| 色综合欧美在线| 亚洲国产日韩精品| 日韩欧美在线网站| 国产成都精品91一区二区三| 视频一区二区国产| 久久精品视频免费| 成人综合婷婷国产精品久久免费| 国产精品欧美综合在线| 色综合天天综合色综合av | 国产网站一区二区| a级高清视频欧美日韩| 一区二区久久久久久| 91精品国产色综合久久| 国产精品性做久久久久久| 一区在线观看视频| 欧美久久久久久久久中文字幕| 国精产品一区一区三区mba视频|