⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zipstorage.h

📁 ZIP压缩代码:基于开源ZipArchive和zlib
💻 H
📖 第 1 页 / 共 2 页
字号:

	/**
		Return the position in the file, taking into account the bytes in the write buffer.
		\note Throws exceptions.
	*/
	DWORD GetPosition() const {return (DWORD)(m_pFile->GetPosition()) + m_uBytesInWriteBuffer;}


	/**
		Flush the data from the read buffer to the disk.
		\note Throws exceptions.
	*/
	void Flush();


	/**
		Forces any data remaining in the file buffer to be written to the disk
	*/
	void FlushFile()
	{
		if (!m_bInMemory && !IsReadOnly())
			m_pFile->Flush();
	}

/**
	A method used to change disks during writing to the disk spanning archive.
	\param	iNeeded
		no of bytes needed on the disk
	\param	lpszFileName
		the archive filename
	\note Throws exceptions.
*/
	void NextDisk(int iNeeded, LPCTSTR lpszFileName = NULL);


/**
	\return a zero-based number of the current disk
*/
	int GetCurrentDisk() const {return m_iCurrentDisk;}

 
/**
	Change the disk during extract operations.
	\param	iNumber
		a zero-based disk number requested
	\return	
*/
	void ChangeDisk(int iNumber);

/**
	Detect the span mode.
	\return	
		- -1 - existing disk spanning archive opened
		- 0 - no disk spanning archive
		- 1 - disk spanning archive in creation

*/
	int IsSpanMode() const
	{
		return m_iSpanMode == noSpan ? 0 : (m_bNewSpan ? 1 : -1);
	}

	/**
		return \c true if the archive cannot be modified.
	*/
	bool IsReadOnly()
	{
		return m_bReadOnly || IsSpanMode() < 0;
	}

/**
	
	\param	bAfterException
		set to \c true after the library has throw an exception.
		The simplified mode is used then.
		In this case it'll be possible to reuse the object to operate on another
		archive, but the current archive file will not be valid anyway.
	\return the filepath of the archive (used by CZipArchive::Close)
	\note Throws exceptions.
*/
	CZipString Close(bool bAfterException);


	/**
		The size of the write buffer. 
		Set before opening the archive. 
		It is usually set with CZipArchive::SetAdvanced
		(specify this value as the first argument).
		\see CZipArchive::SetAdvanced
	*/
	int m_iWriteBufferSize;


	/**
		The physical archive file (on a storage device).
		Not used when opening archive in memory
		with Open(CZipMemFile& , int).
	*/
	CZipFile m_internalfile;

	/**
		The buffer representing the archive. 
		It is a physical file or a memory buffer depending on what
		method was used to open the archive. In the first case it is 
		a pointer to #m_internalfile.
		\see Open(LPCTSTR, int, int);
		\see Open(CZipMemFile& mf, int)
		
	*/
	CZipAbstractFile* m_pFile;	

	/**
		Takes one of the values of #ZipSpanMode.	
	*/
	int m_iSpanMode;

	/**
		A callback functor which method \c Callback is called when there is a need for a disk change 
		while operating on a #pkzipSpan archive.
		\see CZipArchive::SetSpanCallback
	*/
	CZipSpanCallback* m_pChangeDiskFunc;

	/**
		The signature of the extended header	
	*/
	static char m_gszExtHeaderSignat[];
protected:

	/**
		Flush without writing. Can be used only on non-disk spanning archives.
	*/
	void EmptyWriteBuffer()
	{
		m_uBytesInWriteBuffer = 0;
	}

/**
	Open a physical file.
	\param	lpszName
		the name of the file to open
	\param	uFlags
		file open flags
	\param	bThrow
		if \c true then throw an exception in case of failure
	\return	\c true if successful
*/
	bool OpenFile(LPCTSTR lpszName, UINT uFlags, bool bThrow = true);
/**
	Throw an exception with the given code.
	\param	err
	\see CZipException::Throw
*/
	void ThrowError(int err);

/**
	Return the number of bytes left on the current volume.		
*/
	DWORD VolumeLeft() const;

	/**
		Rename last file in TD mode disk spanning archive when done with creating
	*/
	CZipString RenameLastFileInTDSpan();
/**
	Write data to the internal buffer.
	\param	*pBuf
		the buffer to copy data from
	\param	uSize
		bytes to write
	\note Throws exceptions.
*/
	void WriteInternalBuffer(const char *pBuf, DWORD uSize);

/**
	\return	the number of free bytes on the current removable disk
*/
	DWORD GetFreeVolumeSpace() const;

/**
	Call the callback functor.
	Throw an exception if the callback functor's method \c Callback returns \c false.
	\param	iCode
		a code to be passed to the callback functor
	\param	szTemp
		a string to be used as a filename (the second argument
		of CZipException::Throw) when the exception must be thrown
	\note Throws exceptions.
	\see CZipArchive::SetSpanCallback
	\see CZipException::Throw
*/
	void CallCallback(int iCode, CZipString szTemp);


/**
	Construct the name of the volume in #tdSpan mode.
	\param	bLast
		must be \c true if constructing the last volume name (an extension "zip" is given)
	\param	lpszZipName
		the name of the archive
	\return	
		the new volume name
*/
	CZipString GetTdVolumeName(bool bLast, LPCTSTR lpszZipName = NULL) const;

	/**
		Change the disk in #tdSpan mode
	*/
	CZipString ChangeTdRead();

	/**
		Change the disk in #pkzipSpan mode
	*/
	CZipString ChangePkzipRead();
	

	/**
		Used only in \ref TDSpan "TD span mode" . The value it holds depends on the open mode.
		- Opened existing disk spanning archive - store the number of the last
		disk ( the one with "zip" extension).
		- Disk spanning archive in creation - the size of the volume.

		\see CZipArchive::Open
		\see CZipArchive::GetSpanMode

	*/
	int m_iTdSpanData;
	
	/**
		The extension of the last volume.
	*/
	CZipString m_szSpanExtension;

	/**
		\return	the count bytes left free in the write buffer
	*/
	DWORD GetFreeInBuffer() const {return m_pWriteBuffer.GetSize() - m_uBytesInWriteBuffer;}
	
	/**
		Number of bytes available in the write buffer.		
	*/
	DWORD m_uBytesInWriteBuffer;

/**
	The value it holds depends on the open mode:
	\par
	- #tdSpan : the total size of the current volume
	- #pkzipSpan: a free space on the current volume
*/
	DWORD m_uCurrentVolSize;


	/**
		number of bytes left free in the write buffer		
	*/
	DWORD m_uVolumeFreeInBuffer;

	/**
		Write buffer caching data.
	*/
	CZipAutoBuffer m_pWriteBuffer;


	/**
		Used only during disk spanning archive creation.
		Tells how many bytes have been written physically to the current volume.
	*/
	DWORD m_iBytesWritten;

	/**
		\c True, if the current archive is a new disk spanning archive.
	*/
	bool m_bNewSpan;

	/**
		The current disk in a disk spanning archive.
		Disk no 0 is the first disk.
	*/
	int m_iCurrentDisk;

	/**
		It is set to \e true when an archive is created in memory; \e false otherwise.
	*/
	bool m_bInMemory;

	/**
		It is set to \e true if OpenMode::zipOpenReadOnly was specified when opening the archive
	*/
	bool m_bReadOnly;
	
};

#endif // !defined(AFX_ZIPSTORAGE_H__941824FE_3320_4794_BDE3_BE334ED8984B__INCLUDED_)

⌨️ 快捷键说明

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