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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? zipfile.cpp

?? winzip 開發(fā)環(huán)境:C++
?? CPP
字號:
// ZipFile.cpp: implementation of the CZipFile class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ZipFile.h"


#ifndef VERSIONMADEBY
# define VERSIONMADEBY   (0x0) /* platform depedent */
#endif

#define FLAG_LOCALHEADER_OFFSET (0x06)
#define CRC_LOCALHEADER_OFFSET  (0x0e)

#define SIZECENTRALHEADER (0x2e) /* 46 */



#ifndef Z_BUFSIZE
#define Z_BUFSIZE (16384)
#endif

#ifndef Z_MAXFILENAMEINZIP
#define Z_MAXFILENAMEINZIP (256)
#endif

#ifndef DEF_MEM_LEVEL
#if MAX_MEM_LEVEL >= 8
#  define DEF_MEM_LEVEL 8
#else
#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
#endif
#endif

#define SIZEDATA_INDATABLOCK (4096-(4*4))

#define LOCALHEADERMAGIC    (0x04034b50)
#define CENTRALHEADERMAGIC  (0x02014b50)
#define ENDHEADERMAGIC      (0x06054b50)


#define SIZECENTRALHEADER (0x2e) /* 46 */

// it doesn't compile anyway
// const char z_copyright[] =
//    " unzip & zip 0.15 Copyright 1998 Gilles Vollant & MFC/C++ revision Copyright 2000 Tadeusz Dracz";

#define ZIP_PARAMERROR                  (-102)

zip_fileinfo::zip_fileinfo()
{
	tmz_date = CTime::GetCurrentTime();
	dosDate = internal_fa = external_fa = 0;
}

uLong zip_fileinfo::get_dos_date()
{
	if (dosDate)
		return dosDate;

    uLong year = (uLong)tmz_date.GetYear();
    if (year>1980)
        year-=1980;
    else if (year>80)
        year-=80;
    return
      (uLong) ((tmz_date.GetDay() + 32 * tmz_date.GetMonth() + 512 * year) << 16) |
        (tmz_date.GetSecond() / 2 + 32 * tmz_date.GetMinute() + 2048 * (uLong)tmz_date.GetHour());

}

void curfile_info::alloc_central_header()
{
	ASSERT(!central_header);
	if (size_centralheader)
		central_header = new char[size_centralheader];
}

void curfile_info::free_central_header()
{
	if (central_header)
	{
		delete[] central_header;
		central_header = NULL;
	}
}


curfile_info::curfile_info()
{
	buffered_data = new Byte [Z_BUFSIZE];
	central_header = NULL;
}

curfile_info::~curfile_info()
{
	free_central_header();
	delete[] buffered_data;	
}

linkedlist_datablock_internal::linkedlist_datablock_internal()
{
	next_datablock = NULL;
	avail_in_this_block = SIZEDATA_INDATABLOCK;
	filled_in_this_block = 0;
	data = new unsigned char [SIZEDATA_INDATABLOCK];
}

linkedlist_datablock_internal::~linkedlist_datablock_internal()
{
	delete[] data;
}


linkedlist_data::linkedlist_data()
{
	first_block = last_block = NULL;
}

linkedlist_data::~linkedlist_data()
{
	linkedlist_datablock_internal* b = first_block;
	while (b)
	{
		linkedlist_datablock_internal* a = b->next_datablock;
		delete b;
		b = a;
	}
}


void linkedlist_data::add_data_in_datablock(char* buf, uLong len)
{
    if (!last_block)
        first_block = last_block = new linkedlist_datablock_internal;

    linkedlist_datablock_internal* ldi = last_block;

    while (len>0)
    {
        uInt copy_this;
        unsigned char* to_copy;

        if (ldi->avail_in_this_block == 0)
        {
            ldi->next_datablock = new linkedlist_datablock_internal;
            ldi = ldi->next_datablock ;
            last_block = ldi;
        }

        if (ldi->avail_in_this_block < len)
            copy_this = (uInt)ldi->avail_in_this_block;
        else
            copy_this = (uInt)len;

        to_copy = &(ldi->data[ldi->filled_in_this_block]);

		memcpy(to_copy, buf, copy_this);

        ldi->filled_in_this_block += copy_this;
        ldi->avail_in_this_block -= copy_this;
        buf += copy_this ;
        len -= copy_this;
    }
}

int linkedlist_data::write_datablock(CFile & f)
{
    linkedlist_datablock_internal* ldi;
    ldi = first_block;
	int size = 0;
    while (ldi)
    {
        if (ldi->filled_in_this_block > 0)
			f.Write(ldi->data, (uInt)ldi->filled_in_this_block);

		size += ldi->filled_in_this_block;
        ldi = ldi->next_datablock;
    }
	return size;
}

zip_internal::zip_internal()
{
	in_opened_file_inzip = 0;
	ci.stream_initialised = 0;
	number_entry = 0;
}
zip_internal::~zip_internal()
{

}

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CZipFile::CZipFile()
{

	m_pFile = &zi.filezip;
}


CZipFile::CZipFile(LPCTSTR pathname, bool append)
{
	m_pFile = &zi.filezip;
	Open(pathname, append);
}

void CZipFile::Open(LPCTSTR pathname, bool append)
{
	if (!IsClosed())
		return;
	CFileException* e = new CFileException;
	if (!zi.filezip.Open(pathname, (append ? CFile::modeNoTruncate : CFile::modeCreate)|CFile::modeWrite | CFile::shareDenyWrite, e))
		throw e;
	e->Delete();

	zi.filezip.SeekToEnd();
	zi.begin_pos = zi.filezip.GetPosition();
	
}


CZipFile::~CZipFile()
{
// 	Close(); // cannot be here: if an exception is thrown strange things can happen
}

/* ===========================================================================
   Outputs a long in LSB order to the given file
   nbByte == 1, 2 or 4 (byte, short or long)
*/

void CZipFile::ziplocal_putValue(uLong x, int nbByte)
{
    unsigned char buf[4];
    int n;
    for (n = 0; n < nbByte; n++) {
        buf[n] = (unsigned char)(x & 0xff);
        x >>= 8;
    }
    zi.filezip.Write(buf, nbByte);
}

void CZipFile::ziplocal_putValue_inmemory(Byte dest, uLong x, int nbByte)
{
    unsigned char* buf=(unsigned char*)zi.ci.central_header + dest;
    int n;
    for (n = 0; n < nbByte; n++) 
	{
        buf[n] = (unsigned char)(x & 0xff);
        x >>= 8;
	}
}


// 
void CZipFile::OpenNewFileInZip (CString filename, 
								zip_fileinfo& zipfi, 
								int level,
								CString comment, 
								const void* extrafield_local, 
								uInt size_extrafield_local, 
								const void* extrafield_global, 
								uInt size_extrafield_global, 
								int method)
{
    if ((method != Z_DEFLATED) || (!level)) 
        ThrowError(ZIP_PARAMERROR);


    if (zi.in_opened_file_inzip == 1)
        CloseFileInZip();

	if (filename.IsEmpty())
		filename = "-";

	zi.ci.dosDate = zipfi.get_dos_date();

    zi.ci.flag = 0;
    if ((level == 8) || (level == 9))
      zi.ci.flag |= 2;
    if (level == 2)
      zi.ci.flag |= 4;
    if (level == 1)
      zi.ci.flag |= 6;

    zi.ci.crc32 = 0;
    zi.ci.method = method;
    zi.ci.stream_initialised = 0;
    zi.ci.pos_in_buffered_data = 0;
    zi.ci.pos_local_header = zi.filezip.GetPosition();
    zi.ci.size_centralheader = SIZECENTRALHEADER + filename.GetLength() + 
                                      size_extrafield_global + comment.GetLength();

    zi.ci.alloc_central_header();

    ziplocal_putValue_inmemory(0, (uLong)CENTRALHEADERMAGIC,4);
    /* version info */
    ziplocal_putValue_inmemory(4,(uLong)VERSIONMADEBY,2);
    ziplocal_putValue_inmemory(6,(uLong)20, 2);
    ziplocal_putValue_inmemory(8,(uLong)zi.ci.flag,2);
    ziplocal_putValue_inmemory(10,(uLong)zi.ci.method,2);
    ziplocal_putValue_inmemory(12,(uLong)zi.ci.dosDate,4);
    ziplocal_putValue_inmemory(16,(uLong)0, 4); /*crc*/
    ziplocal_putValue_inmemory(20,(uLong)0, 4); /*compr size*/
    ziplocal_putValue_inmemory(24,(uLong)0, 4); /*uncompr size*/
    ziplocal_putValue_inmemory(28,(uLong)filename.GetLength(), 2);
    ziplocal_putValue_inmemory(30,(uLong)size_extrafield_global,2);
    ziplocal_putValue_inmemory(32,(uLong)comment.GetLength(), 2);
    ziplocal_putValue_inmemory(34,(uLong)0, 2); /*disk nm start*/

	ziplocal_putValue_inmemory(36,(uLong)zipfi.internal_fa, 2); 
	ziplocal_putValue_inmemory(38,(uLong)zipfi.external_fa, 4);

    ziplocal_putValue_inmemory(42,(uLong)zi.ci.pos_local_header, 4);

	char* pDest = zi.ci.central_header + SIZECENTRALHEADER;
	memcpy(pDest, (LPCTSTR)filename, filename.GetLength());
	pDest += filename.GetLength();
	memcpy(pDest, extrafield_global, size_extrafield_global);
	pDest += size_extrafield_global;
	memcpy(pDest, (LPCTSTR)comment, comment.GetLength());

    /* write the local header */
    ziplocal_putValue((uLong)LOCALHEADERMAGIC, 4);
	ziplocal_putValue((uLong)20, 2);/* version needed to extract */
    ziplocal_putValue((uLong)zi.ci.flag, 2);
	ziplocal_putValue((uLong)zi.ci.method, 2);
	ziplocal_putValue((uLong)zi.ci.dosDate, 4);
	ziplocal_putValue((uLong)0, 4); /* crc 32, unknown */
    ziplocal_putValue((uLong)0, 4); /* compressed size, unknown */
	ziplocal_putValue((uLong)0, 4); /* uncompressed size, unknown */
	ziplocal_putValue((uLong)filename.GetLength(), 2);
	ziplocal_putValue((uLong)size_extrafield_local, 2);

	zi.filezip.Write(filename, filename.GetLength());

	if (size_extrafield_local > 0)
		zi.filezip.Write(extrafield_local, size_extrafield_local);

    zi.ci.stream.avail_in = (uInt)0;
    zi.ci.stream.avail_out = (uInt)Z_BUFSIZE;
    zi.ci.stream.next_out = zi.ci.buffered_data;
    zi.ci.stream.total_in = 0;
    zi.ci.stream.total_out = 0;

    if ((zi.ci.method == Z_DEFLATED))
    {
        zi.ci.stream.zalloc = (alloc_func)myalloc;
        zi.ci.stream.zfree = (free_func)myfree;
        zi.ci.stream.opaque = m_bDetectZlibMemoryLeaks ? &m_list : 0;

        int err = deflateInit2(&zi.ci.stream, level,
               Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);

		CheckForError(err);
        zi.ci.stream_initialised = 1;
    }


        zi.in_opened_file_inzip = 1;

}


void CZipFile::WriteInFileInZip(const void *buf, UINT len)
{
    if (zi.in_opened_file_inzip == 0)
        ThrowError(ZIP_PARAMERROR);

    zi.ci.stream.next_in = (unsigned char*)buf;
    zi.ci.stream.avail_in = len;
    zi.ci.crc32 = crc32(zi.ci.crc32, (unsigned char*)buf, len);

	int err = Z_OK;

    while ((err == Z_OK) && (zi.ci.stream.avail_in > 0))
    {

        if (zi.ci.stream.avail_out == 0)
        {
			zi.filezip.Write(zi.ci.buffered_data, zi.ci.pos_in_buffered_data);
            zi.ci.pos_in_buffered_data = 0;
            zi.ci.stream.avail_out = (uInt)Z_BUFSIZE;
            zi.ci.stream.next_out = zi.ci.buffered_data;
        }

        if (zi.ci.method == Z_DEFLATED)
        {
            uLong uTotalOutBefore = zi.ci.stream.total_out;
            err = deflate(&zi.ci.stream,  Z_NO_FLUSH);
            zi.ci.pos_in_buffered_data += (uInt)(zi.ci.stream.total_out - uTotalOutBefore) ;
        }
        else
        {
            uInt copy_this;
            if (zi.ci.stream.avail_in < zi.ci.stream.avail_out)
                copy_this = zi.ci.stream.avail_in;
            else
                copy_this = zi.ci.stream.avail_out;

			memcpy(zi.ci.stream.next_out, zi.ci.stream.next_in, copy_this);

            zi.ci.stream.avail_in -= copy_this;
            zi.ci.stream.avail_out -= copy_this;
            zi.ci.stream.next_in += copy_this;
            zi.ci.stream.next_out += copy_this;
            zi.ci.stream.total_in += copy_this;
            zi.ci.stream.total_out += copy_this;
            zi.ci.pos_in_buffered_data += copy_this;
        }
    }

	CheckForError(err);

}


void CZipFile::CloseFileInZip()
{
    if (zi.in_opened_file_inzip == 0)    
        return;

	int err = Z_OK;

    zi.ci.stream.avail_in = 0;
    
    if (zi.ci.method == Z_DEFLATED)
        while (err == Z_OK)
		{
			uLong uTotalOutBefore;
			if (zi.ci.stream.avail_out == 0)
			{
				zi.filezip.Write(zi.ci.buffered_data, zi.ci.pos_in_buffered_data);
				zi.ci.pos_in_buffered_data = 0;
				zi.ci.stream.avail_out = (uInt)Z_BUFSIZE;
				zi.ci.stream.next_out = zi.ci.buffered_data;
			}
			uTotalOutBefore = zi.ci.stream.total_out;
			err = deflate(&zi.ci.stream,  Z_FINISH);
			zi.ci.pos_in_buffered_data += (uInt)(zi.ci.stream.total_out - uTotalOutBefore) ;
		}

    if (err == Z_STREAM_END)
        err = Z_OK; /* this is normal */

	CheckForError(err);

	if (zi.ci.pos_in_buffered_data > 0)
		zi.filezip.Write(zi.ci.buffered_data, zi.ci.pos_in_buffered_data);

	if (zi.ci.method == Z_DEFLATED)
	{
		err = deflateEnd(&zi.ci.stream);
		zi.ci.stream_initialised = 0;
	}

	CheckForError(err);

	ziplocal_putValue_inmemory(16, (uLong)zi.ci.crc32, 4); /*crc*/
	ziplocal_putValue_inmemory(20, (uLong)zi.ci.stream.total_out, 4); /*compr size*/
	ziplocal_putValue_inmemory(24, (uLong)zi.ci.stream.total_in, 4); /*uncompr size*/

	zi.central_dir.add_data_in_datablock(zi.ci.central_header, (uLong)zi.ci.size_centralheader);

	zi.ci.free_central_header();

    long cur_pos_inzip = zi.filezip.GetPosition();
	zi.filezip.Seek(zi.ci.pos_local_header + 14, CFile::begin);
	ziplocal_putValue((uLong)zi.ci.crc32, 4); /* crc 32, unknown */
    ziplocal_putValue((uLong)zi.ci.stream.total_out, 4);/* compressed size, unknown */
	ziplocal_putValue((uLong)zi.ci.stream.total_in, 4); /* uncompressed size, unknown */
	zi.filezip.Seek(cur_pos_inzip, CFile::begin);

    zi.number_entry++;
    zi.in_opened_file_inzip = 0;
}

void CZipFile::Close(CString global_comment)
{

	if (IsClosed())
		return;

    if (zi.in_opened_file_inzip == 1)
        CloseFileInZip ();


    uLong centraldir_pos_inzip = zi.filezip.GetPosition();

	uLong size_centraldir = zi.central_dir.write_datablock(zi.filezip);
    

    /* Magic End */
    ziplocal_putValue((uLong)ENDHEADERMAGIC, 4);
	ziplocal_putValue((uLong)0, 2);/* number of this disk */
	ziplocal_putValue((uLong)0, 2);/* number of the disk with the start of the central directory */
    ziplocal_putValue((uLong)zi.number_entry, 2);/* total number of entries in the central dir on this disk */
    ziplocal_putValue((uLong)zi.number_entry,2);/* total number of entries in the central dir */
	ziplocal_putValue((uLong)size_centraldir,4);/* size of the central directory */
	ziplocal_putValue((uLong)centraldir_pos_inzip ,4);/* offset of start of central directory with respect to the starting disk number */
	ziplocal_putValue((uLong)global_comment.GetLength(), 2);/* zipfile comment length */
	if (!global_comment.IsEmpty())
		zi.filezip.Write(global_comment, global_comment.GetLength());

	zi.filezip.Close();

}

void CZipFile::UpdateZipInfo(zip_fileinfo &zi, CFile &f)
{
	CFileStatus fs;
	f.GetStatus(fs);
	zi.tmz_date = fs.m_mtime;
	zi.external_fa = ::GetFileAttributes(f.GetFilePath()); // mfc bug: m_attribute is 1-byte

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人精品免费视频| 亚洲欧美日韩精品久久久久| 欧美一级在线观看| wwwwww.欧美系列| 亚洲天堂福利av| 爽好久久久欧美精品| 国产一区二区成人久久免费影院| 成人涩涩免费视频| 中文字幕中文乱码欧美一区二区| 亚洲一区二区成人在线观看| 国产一区在线观看视频| 国产女同互慰高潮91漫画| 午夜精品久久一牛影视| 91香蕉视频污| 亚洲蜜臀av乱码久久精品蜜桃| 日韩成人dvd| www.亚洲色图| 精品国产制服丝袜高跟| 亚洲最色的网站| av网站免费线看精品| 亚洲美女免费在线| 欧美一级欧美一级在线播放| 国产一区二区视频在线播放| 国产精品久久久久久久久搜平片| 欧美在线播放高清精品| 久久欧美一区二区| 久久国产精品99久久久久久老狼 | 岛国一区二区三区| 欧美国产日本韩| 精品综合免费视频观看| 欧美日本国产视频| 亚洲综合男人的天堂| 日韩小视频在线观看专区| 亚洲国产日韩精品| 91一区一区三区| 日韩在线一二三区| 亚洲欧洲在线观看av| 成人精品一区二区三区中文字幕| 亚洲香肠在线观看| 国产精品视频九色porn| 成人精品电影在线观看| 日本一区二区电影| 欧美电影在线免费观看| 日本欧美肥老太交大片| 国产精品天天摸av网| 日韩一区二区三区四区| 在线观看一区二区视频| av不卡一区二区三区| 久久er99精品| 午夜精品爽啪视频| 一区二区久久久久| 国产精品美日韩| 2021久久国产精品不只是精品| 欧美放荡的少妇| 在线精品视频一区二区三四 | 99精品国产视频| 一区二区三区在线观看视频| 久久精品人人做人人爽人人| 成人动漫视频在线| 国产美女在线观看一区| 久久疯狂做爰流白浆xx| 日本va欧美va欧美va精品| 久久久久国产精品厨房| 日韩精品一区二区三区在线| 国产精品自拍av| 18涩涩午夜精品.www| 欧美国产丝袜视频| 国产欧美一区视频| 国产丝袜在线精品| 国产日韩欧美在线一区| 欧美精品一区二区三区视频| 欧美一卡二卡在线| 欧美一级在线视频| 欧美不卡视频一区| av不卡在线观看| av激情亚洲男人天堂| jlzzjlzz国产精品久久| 国产v综合v亚洲欧| 亚洲va在线va天堂| 中文字幕国产一区二区| 国产校园另类小说区| 国产欧美日韩卡一| 中文字幕在线不卡一区二区三区| 中文字幕+乱码+中文字幕一区| 国产欧美一区二区精品性色| 国产日韩欧美精品综合| 国产精品嫩草久久久久| 亚洲精品成人在线| 精品va天堂亚洲国产| 久久影院午夜论| 国产精品久久国产精麻豆99网站| 综合色天天鬼久久鬼色| 一区二区三区不卡在线观看 | 国产成a人亚洲| 成人激情午夜影院| 欧美中文字幕一二三区视频| 欧美日韩亚洲综合在线 | 成人黄色av网站在线| 97久久超碰国产精品电影| 色久优优欧美色久优优| 国产成人av电影免费在线观看| 成人精品免费网站| 欧美性大战久久久久久久蜜臀 | 亚洲男人电影天堂| 亚洲成av人片一区二区梦乃| 日本网站在线观看一区二区三区 | 欧美成人精品3d动漫h| 久久久91精品国产一区二区精品| 欧美激情一区在线| 亚洲最快最全在线视频| 久久精品国产77777蜜臀| 成人黄色大片在线观看| 欧美人妇做爰xxxⅹ性高电影| 2023国产精品| 一区二区在线观看免费| 精品一区二区精品| 色吊一区二区三区| 精品国产99国产精品| 亚洲另类一区二区| 国产在线播放一区| 欧美三级日本三级少妇99| 久久久久久免费| 午夜影院久久久| 99久久精品免费观看| 欧美xxxx老人做受| 亚洲毛片av在线| 国产传媒久久文化传媒| 国产 欧美在线| 7878成人国产在线观看| 欧美肥妇free| 亚洲四区在线观看| 国产一区二区三区综合| 欧美在线一区二区三区| 久久久精品国产免大香伊| 亚洲高清免费视频| 99国产欧美久久久精品| 亚洲精品在线观看网站| 亚洲国产aⅴ成人精品无吗| www.欧美日韩| 久久嫩草精品久久久精品| 亚洲mv大片欧洲mv大片精品| 成av人片一区二区| 久久亚洲精品小早川怜子| 婷婷开心激情综合| 91成人网在线| 中文字幕五月欧美| 国产激情精品久久久第一区二区| 欧美高清你懂得| 亚洲制服丝袜av| 91香蕉视频污在线| 中文字幕佐山爱一区二区免费| 国产乱对白刺激视频不卡| 91精品国产综合久久香蕉的特点 | 国产精品1区二区.| 日韩女优av电影在线观看| 视频一区国产视频| 欧美人伦禁忌dvd放荡欲情| 亚洲自拍偷拍欧美| 欧美亚洲自拍偷拍| 一区二区三区成人| 欧美在线一二三四区| 一区二区三区在线视频播放| 不卡区在线中文字幕| 国产精品美女一区二区三区| 国产成人在线色| 欧美激情综合五月色丁香| 成人午夜精品在线| 国产精品盗摄一区二区三区| 成人av电影在线网| 亚洲色图20p| 色综合天天综合色综合av | 欧美一级国产精品| 美女视频免费一区| 色美美综合视频| 亚洲福利一二三区| 欧美日韩视频第一区| 免费在线观看一区| 精品久久五月天| 成人午夜在线免费| 一区二区三区中文在线观看| 欧美中文字幕一二三区视频| 日韩精品一级二级 | 亚洲综合免费观看高清在线观看| 欧美亚洲国产一区二区三区va| 亚洲一级不卡视频| 欧美一区二区三区在线电影| 美女任你摸久久| 精品国产乱码久久久久久久久 | 国产一区欧美日韩| 国产精品理论在线观看| 91国偷自产一区二区三区成为亚洲经典 | 国产成人在线色| 日韩一区欧美小说| 精品视频免费在线| 国产综合色精品一区二区三区| 欧美男女性生活在线直播观看| 美女mm1313爽爽久久久蜜臀| 国产喂奶挤奶一区二区三区| 在线观看免费一区| 久久爱www久久做|