zip.cpp

来自「VC做的学生信息管理系统」· C++ 代码 · 共 59 行

CPP
59
字号
// Zip.cpp: implementation of the CZip class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Note.h"
#include "Zip.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

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

CZip::CZip(CString strInputFile)
{
  m_strFileName=strInputFile;
  ASSERT(!m_strFileName.IsEmpty());

}

CZip::~CZip()
{

}

void CZip::SwapSize(CString strOutputFile)
{
	
	ASSERT(!strOutputFile.IsEmpty());
	ASSERT(strOutputFile.CompareNoCase(m_strFileName));
	CZipFile zf(strOutputFile, 0);
	char buf[BUF_SIZE];

	CFile file(m_strFileName, CFile::modeRead);

	zip_fileinfo zi;
	zf.UpdateZipInfo(zi, file);

	zf.OpenNewFileInZip(m_strFileName, zi, Z_BEST_COMPRESSION);

	int size_read;
	do
	{
		size_read = file.Read(buf, BUF_SIZE);
		if (size_read)
			zf.WriteInFileInZip(buf, size_read);
		
	}
	while (size_read == BUF_SIZE);
    zf.Close();

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?