www.pudn.com > SharedScreen.rar > LZWFILE.H


#ifndef ___LZWFILE_H 
#define ___LZWFILE_H 
 
#include "lzwtable.h"    
#include "lzwcode.h" 
 
/* 
HGLZ file: 
	lzw file head 
	{ 
		for(i) 
		{ 
			node head 
			for(j) 
			{ 
				single file head 
				compressed file data 
				. 
				. 
				. 
				single file head 
				compressed file data 
			} 
		} 
	} 
 
compress file data: 
	lzw clear code 
	data 
	lzw end data 
*/ 
#define LZW_FILE_TAG	((DWORD)'H'|(DWORD)'G'<<8|(DWORD)'L'<<16|(DWORD)'Z'<<24) 
/*HGLZ*/ 
#define LZW_NODE_CHANGE_DIRECTORY		0X00 
#define LZW_NODE_GOTO_BEGIN				0X80 
#define LZW_NODE_BEGIN_COMPRESS			0X90 
#define LZW_NODE_TAG					0XEE 
#define LZW_SINGLE_FILE_TAG				0XFF 
#define LZW_MIN_FILE_LENGTH	(sizeof(LZWFILEHEAD)+sizeof(LZWSINGLEFILEHEAD)+sizeof(LZWNODEHEAD)) 
 
typedef struct LZWEncodeSingleFileInfo 
{ 
	DWORD dwOldLength; 
	DWORD dwCompressedLength; 
}LZWENCODESINGLEFILEINFO,*PLZWENCODESINGLEFILEINFO; 
typedef struct LZWFileHead 
{ 
	DWORD dwFileTag;//must be "HGLZ" LZW_FILE_TAG 
	WORD wVersion;//high byte is primary version 
	DWORD dwFileCount; 
}LZWFILEHEAD,*PLZWFILEHEAD; 
typedef struct LZWSingleFileHead 
{ 
	WORD wSingleFileTag;// must be 0XFF lzw_single_file_tag 
	DWORD dwAttribute; 
	DWORD dwFileOldLength;// to caculate the compress ratio 
	DWORD dwFileCompressedLength;// to find the next file head 
	WORD wFileNameLength; 
	// BYTE[] for file name 
}LZWSINGLEFILEHEAD,*PZWSINGLEFILEHEAD; 
typedef struct LZWNodeHead 
{ 
	WORD wNodeTag;// must be 0XEE lzw_node_tag 
	WORD wDirectoryType; 
	// 0x00 : change  
	// 0x80 : goto begin directory 
	// 0x90 : begin to compress 
	WORD wDirectoryNameLength; 
	//BYTE[] for directory name 
}LZWNODEHEAD,*PLZWNODEHEAD; 
 
// compress single file 
BOOL LZWEncodeFile(CFile* pInFile,CFile* pOutFile, 
					FUN_LZWENCODEDBYTES pfunEncodedBytes=NULL); 
// decompress the specified file to some file 
BOOL LZWDecodeFileToFile(CFile* pInFile, 
						CFile* pOutFile, 
						DWORD dwPos=0,//the decompressed file position 
						FUN_LZWDECODEDBYTES pfunDecodedBytes=NULL); 
// decompress the specified file to the directory  
// for batch decompress 
BOOL LZWDecodeFileOnPosition(CFile* pInFile, 
							CFile* pOutFile,// file be decompressed 
							DWORD dwPos=0,//the decompressed file position 
							FUN_LZWDECODEDBYTES pfunDecodedBytes=NULL); 
BOOL LZWParseFileHead(LPCSTR pszInFile,CString *pszOut=NULL); 
BOOL LZWParseFileHead(LPCSTR pszInFile,CStringArray &szNameArray); 
// add a file to a compressed file 
BOOL LZWAddEncodeFile(LPCSTR pszInFile,// file to be added 
						LPCSTR pszOutFile,// compressed file 
						FUN_LZWENCODEDBYTES pfunEncodedBytes=NULL); 
BOOL LZWCheckFile(LPCSTR pszCheck);// is the file a HGLZ 
BOOL LZWCheckFile(CFile* pfileCheck);// is the file a HGLZ 
#endif