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

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

?? zipfile.cpp

?? 學(xué)生信息管理系統(tǒng)x
?? CPP
字號(hào):
// 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

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲18影院在线观看| 欧美熟乱第一页| 国产高清久久久久| 另类专区欧美蜜桃臀第一页| 日韩电影一区二区三区四区| 首页国产欧美日韩丝袜| 日本视频中文字幕一区二区三区| 五月综合激情日本mⅴ| 婷婷六月综合网| 日本人妖一区二区| 日本在线播放一区二区三区| 日本aⅴ精品一区二区三区| 日韩av一区二区三区| 蜜桃精品在线观看| 国产一区免费电影| 成人免费观看男女羞羞视频| 不卡高清视频专区| 在线看一区二区| 69堂精品视频| 精品国产凹凸成av人网站| 26uuu欧美| 国产精品网友自拍| 一区二区三区精品久久久| 亚洲高清在线视频| 久久99蜜桃精品| 成人成人成人在线视频| 欧美色综合网站| 欧美精品精品一区| 精品久久人人做人人爽| 久久久另类综合| 成人免费一区二区三区视频| 亚洲一区中文日韩| 麻豆91精品91久久久的内涵| 国产宾馆实践打屁股91| 在线观看国产一区二区| 日韩无一区二区| 亚洲国产精品精华液2区45| 一区二区三区日韩精品视频| 蜜臀99久久精品久久久久久软件| 丁香亚洲综合激情啪啪综合| 在线欧美小视频| 精品国产一区二区三区久久久蜜月 | 日韩激情中文字幕| 国产激情精品久久久第一区二区| 91免费看视频| 欧美mv日韩mv亚洲| 亚洲免费观看高清完整版在线观看熊 | 亚洲图片欧美综合| 精久久久久久久久久久| 91丝袜美腿高跟国产极品老师 | 欧美日韩精品高清| 久久蜜桃香蕉精品一区二区三区| 亚洲欧美另类久久久精品 | 精品少妇一区二区三区日产乱码| 亚洲国产精品精华液2区45| 午夜久久久久久电影| 懂色中文一区二区在线播放| 91精品一区二区三区在线观看| 国产精品福利一区二区三区| 日本亚洲免费观看| 一本到三区不卡视频| 久久久亚洲高清| 日韩精品欧美精品| 色综合久久88色综合天天| 久久综合色婷婷| 午夜精品一区在线观看| 99精品一区二区| 久久蜜桃一区二区| 日本亚洲最大的色成网站www| 91欧美激情一区二区三区成人| 精品区一区二区| 天堂成人国产精品一区| 97se亚洲国产综合自在线| 欧美成人激情免费网| 亚洲第一综合色| 99免费精品在线观看| 久久嫩草精品久久久久| 天堂精品中文字幕在线| 91国偷自产一区二区三区成为亚洲经典 | 一区二区三区**美女毛片| 成人午夜av电影| 337p粉嫩大胆色噜噜噜噜亚洲| 五月激情综合网| 在线亚洲免费视频| ●精品国产综合乱码久久久久| 国产乱人伦偷精品视频免下载| 欧美日韩精品电影| 一级女性全黄久久生活片免费| 99久久精品一区| 中文字幕中文字幕中文字幕亚洲无线| 国产在线精品免费av| 日韩视频免费直播| 天天免费综合色| 欧美男生操女生| 亚洲chinese男男1069| 欧美亚洲一区二区三区四区| 亚洲精品综合在线| 91蜜桃视频在线| 亚洲视频免费在线观看| 99精品视频在线播放观看| 国产精品欧美一级免费| 成人精品高清在线| 中文字幕亚洲不卡| 99精品久久免费看蜜臀剧情介绍| 国产精品妹子av| 成人av网站大全| 国产精品福利一区二区三区| 99视频在线观看一区三区| 亚洲婷婷综合色高清在线| 99精品热视频| 一区二区三区在线免费观看| 欧美羞羞免费网站| 天天综合日日夜夜精品| 欧美一级艳片视频免费观看| 精品一区二区三区在线播放| 26uuu国产在线精品一区二区| 国产一区激情在线| 国产三区在线成人av| 99久久99久久免费精品蜜臀| 亚洲综合激情另类小说区| 欧美三级日韩三级国产三级| 视频一区二区三区中文字幕| 日韩欧美自拍偷拍| 国产在线精品国自产拍免费| 国产精品污www在线观看| 色伊人久久综合中文字幕| 五月天一区二区三区| 精品国产乱码久久久久久久久 | 欧美中文一区二区三区| 视频在线在亚洲| 久久久久国产精品麻豆| av网站一区二区三区| 亚洲一区二区三区三| 日韩一区二区免费在线电影| 国产精品99久久久久久宅男| 亚洲欧美另类久久久精品2019| 7777女厕盗摄久久久| 国产电影一区在线| 夜夜精品视频一区二区| 91精品国产一区二区三区蜜臀| 国产精品一区一区三区| 亚洲精品成人少妇| 日韩一级黄色大片| 成人高清免费观看| 五月激情丁香一区二区三区| 久久婷婷国产综合精品青草| 91在线免费看| 久久不见久久见中文字幕免费| 国产精品每日更新在线播放网址| 91豆麻精品91久久久久久| 另类小说图片综合网| 亚洲色图都市小说| 日韩欧美第一区| 91丨porny丨户外露出| 日日摸夜夜添夜夜添精品视频| 国产婷婷一区二区| 欧美日韩一区二区三区高清| 大美女一区二区三区| 五月天一区二区三区| 国产精品色眯眯| 在线播放视频一区| 91农村精品一区二区在线| 极品少妇xxxx精品少妇偷拍| 洋洋成人永久网站入口| 欧美激情在线免费观看| 日韩三级电影网址| 色综合视频一区二区三区高清| 精油按摩中文字幕久久| 亚洲五月六月丁香激情| 欧美国产丝袜视频| 欧美大片国产精品| 欧美日韩精品一区二区| 成人免费视频国产在线观看| 免费人成在线不卡| 亚洲成av人片| 亚洲精品免费在线观看| 久久精品一区二区三区四区| 69p69国产精品| 91色.com| 成人免费va视频| 国产一区二区三区国产| 日韩国产欧美三级| 一区二区三区 在线观看视频| 国产精品久久久久影院| 久久一区二区三区四区| 欧美一区二区三区不卡| 欧美日韩视频在线一区二区| 99re热视频这里只精品| 国产成人亚洲综合色影视| 国产综合久久久久影院| 免费成人在线播放| 日韩和的一区二区| 亚洲福利一区二区| 亚洲综合在线免费观看| 亚洲三级理论片| 日韩理论在线观看| 亚洲色图丝袜美腿| 亚洲另类色综合网站| 自拍偷拍亚洲欧美日韩| 国产精品二三区|