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

📄 zipbuilder.h

📁 zip算法的源码
💻 H
📖 第 1 页 / 共 4 页
字号:
    void __fastcall _List(void);
    void __fastcall _Delete(void);
    unsigned __fastcall PerCent(unsigned total, unsigned position); // new 1.73
    static unsigned long __stdcall ZCallback( CallBack::PZCallBackStruct cbr );  // new 1.73
     int    __fastcall CopyBuffer( int &InFile, int &OutFile, int ReadLen );
	public:
		__fastcall TZipBuilder( Classes::TComponent *AOwner );
		__fastcall virtual ~TZipBuilder( void );
		// public properties (run-time only)
		__property HWND            Handle             = {read=FHandle, write=FHandle, nodefault};
		__property int             ErrCode            = {read=FErrCode,        write=FErrCode, nodefault};
		__property String          Message            = {read=FMessage,	     nodefault};
		__property Classes::TList *ZipContents        = {read=FZipContents,    nodefault};
		__property bool            Cancel             = {read=FCancel, write=SetCancel, nodefault};
		__property bool            ZipBusy            = {read=FZipBusy, nodefault};
		__property bool            UnzBusy            = {read=FUnzBusy, nodefault};
		__property int             Count              = {read=GetCount, nodefault};
		__property int             SuccessCnt         = {read=FSuccessCnt, nodefault};
		__property int             ZipVers            = {read=GetZipVers, nodefault};
		__property int             UnzVers            = {read=GetUnzVers, nodefault};
//		__property int MinZipDllVers = {read=fMinZipDllVer, write=SetMinZipDllVers, default=170};  //new 1.70
//		__property int MinUnzDllVers = {read=fMinUnzDllVer, write=SetMinUnzDllVers, default=170};  //new 1.70
		__property int						SFXOffset			 = {read=FSFXOffset,		  default=0};
		__property unsigned long	ZipSOC				 = {read=FZipSOC,			  default=0};
		__property unsigned long	ZipEOC				 = {read=FZipEOC,			  default=0};
		__property bool						IsSpanned			 = {read=FIsSpanned,		  default=false};
		__property long				ZipFileSize			 = {read=FRealFileSize,	  default=0};
		__property int					FullErrCode			 = {read=FFullErrCode,	  write=FFullErrCode, nodefault};
		__property unsigned long   TotalSizeToProcess = {read=FTotalSizeToProcess,    nodefault};
		__property String          ZipComment         = {read=GetZipComment,   write=SetZipComment, nodefault};
		__property int					DirOnlyCount		 = {read=FDirOnlyCount,   default=0};
        	// Just to be compatible with older versions (notice the small 'n').
		__property String	ZipFilename	= {read=FZipFileName, write=SetFileName, nodefault};
		__property ZipDirEntry  DirEntry[int idx] = {read=GetDirEntry}; //new 1.70
#ifndef NO_STREAM
		__property TZipStream	  *ZipStream			 = {read=FZipStream,		  nodefault};
#endif
    static bool __fastcall PatternMatch(const String Pat, const String Subj); // new 1.73
    static bool __fastcall ForceDirectories(const AnsiString Dir);
    static String __fastcall SetSlash(const String path, bool forward=false);
    static String __fastcall DelimitPath(const String path, bool sep=true);
		static bool __fastcall DirExists( const AnsiString Name );
		static String __fastcall FileVersion(String fname);
    static int __fastcall QueryZip(const String Name); // new 1.73
    static String __fastcall PathConcat(String path,String extra); // new 1.73
    		//Public Methods
    String __fastcall LoadZipStr(const int Ident, const String DefaultStr = "" );
		int __fastcall Add(void);    // changed 1.72
		int __fastcall Delete(void); // changed 1.72
		int __fastcall Extract(void); // changed 1.72
		int   __fastcall List( void );
     // load dll - return version
		int   __fastcall Load_Zip_Dll(void );
		int   __fastcall Load_Unz_Dll(void );
		void   __fastcall Unload_Zip_Dll(void );
		void   __fastcall Unload_Unz_Dll(void );
    String __fastcall ZipDllPath(void); //new 1.72
    String __fastcall UnzDllPath(void); //new 1.72
    void   __fastcall AbortDlls(void);  //new 1.72
    bool __fastcall Busy(void); // new 1.72
		int    __fastcall CopyFile( const String src, const String dest );
		int    __fastcall EraseFile( const String Fname, DeleteOpts How );
		String __fastcall GetAddPassword( void );
		String __fastcall GetExtrPassword( void );
		int    __fastcall Rename( TList &RenameList, unsigned long DateTime );
		String __fastcall MakeTempFileName(String Prefix = "zip", String Extension = ".zip");
		void   __fastcall ShowZipMessage( const int Ident, const String UserStr = "");
		TPasswordButton __fastcall GetPassword( String DialogCaption, String MsgTxt, TPasswordButtons pwButtons, String &ResultStr );	// v1.60N changed
		int    __fastcall CopyZippedFiles( TZipBuilder *DestZipBuilder, bool DeleteFromSource, OvrOpts OverwriteDest );
		String __fastcall FullVersionString(void);
    int    __fastcall IsZipSFX( const String SFXExeName );
#ifndef NO_SPAN
		int    __fastcall WriteSpan( const String InFileName, const String OutFileName );
		int    __fastcall ReadSpan( const String InFileName, String &OutFilePath );
#endif
#ifndef NO_SFX
		int    __fastcall ConvertSFX( void );
		int    __fastcall ConvertZIP( void );
#endif
#ifndef NO_STREAM
    TZipStream * __fastcall ExtractFileToStream(String FileName= "");
		int   __fastcall AddStreamToFile(String FileName = "", DWORD FileDate = 0, DWORD FileAttr = 0); // changed 1.72
		TZipStream * __fastcall ExtractStreamToStream( TMemoryStream *InStream, unsigned long OutSize = 32768 );
		TZipStream * __fastcall AddStreamToStream( TMemoryStream *InStream );
#endif

	__published:
		__property bool Verbose = {read=FVerbose, write=FVerbose, nodefault};
		__property bool Trace = {read=FTrace, write=FTrace, nodefault};
		__property int AddCompLevel = {read=FAddCompLevel, write=FAddCompLevel, default=9};
		__property AddOpts AddOptions = {read=FAddOptions, write=FAddOptions, nodefault};
#ifndef NO_SPAN
    __property SpanOpts SpanOptions = {read=FSpanOptions, write=FSpanOptions, nodefault};
#endif
		__property String ExtrBaseDir = {read=FExtrBaseDir, write=FExtrBaseDir, nodefault};
		__property ExtrOpts ExtrOptions = {read=FExtrOptions, write=FExtrOptions, nodefault};
		__property Classes::TStrings *FSpecArgs = {read=FFSpecArgs, write=SetFSpecArgs, nodefault};
		__property bool Unattended = {read=FUnattended, write=FUnattended, default=false};
		__property String ZipFileName = {read=FZipFileName, write=SetFileName, nodefault};
		__property String	Password = {read=FPassword, write=FPassword, nodefault};
		__property String	DLLDirectory = {read=FDLLDirectory,	write=SetDLLDirectory, nodefault};
		__property String	TempDir = {read=FTempDir,	write=FTempDir, nodefault};
		__property CPOpts CodePage = {read=FCodePage, write=FCodePage, default=cpAuto};
		__property DeleteOpts HowToDelete = {read=FHowToDelete, write=FHowToDelete, default=htdAllowUndo};
		__property String VersionInfo = {read=FVersionInfo, write=SetVersionInfo};
		__property AddStoreExts AddStoreSuffixes = {read=FAddStoreSuffixes, write=FAddStoreSuffixes,   nodefault};
    __property String ExtAddStoreSuffixes = {read=FExtAddStoreSuffixes,
                                         write=SetExtAddStoreSuffixes, nodefault}; // new 1.71
		__property unsigned int PasswordReqCount = {read=FPasswordReqCount, write=SetPasswordReqCount, default=1};
		__property Classes::TStrings *FSpecArgsExcl = {read=FFSpecArgsExcl, write=SetFSpecArgsExcl, nodefault};
		__property bool UseDirOnlyEntries = {read=FUseDirOnlyEntries, write = FUseDirOnlyEntries, default=false };
		__property String RootDir = {read=FRootDir,	write=SetRootDir};
    __property TDateTime AddFrom = {read=FFromDate, write=FFromDate, nodefault};

		//Events
		__property Classes::TNotifyEvent	OnDirUpdate	= { read=FOnDirUpdate, write=FOnDirUpdate};
		__property TProgressEvent OnProgress	= { read=FOnProgress,	write=FOnProgress};
		__property TMsgEvent OnMessage = { read=FOnMessage, write=FOnMessage};
		__property TSetNewNameEvent OnSetNewName = { read=FOnSetNewName, write=FOnSetNewName};
		__property TNewNameEvent OnNewName = { read=FOnNewName, write=FOnNewName};
		__property TCRC32ErrorEvent OnCRC32Error = { read=FOnCRC32Error, write=FOnCRC32Error};
		__property TPasswordErrorEvent OnPasswordError = { read=FOnPasswordError, write=FOnPasswordError};
		__property TExtractOverwriteEvent OnExtractOverwrite = {read=FOnExtractOverwrite, write=FOnExtractOverwrite};
		__property TExtractSkippedEvent	 OnExtractSkipped	 = {read=FOnExtractSkipped,	 write=FOnExtractSkipped};
		__property TCopyZipOverwriteEvent OnCopyZipOverwrite = {read=FOnCopyZipOverwrite, write=FOnCopyZipOverwrite};
		__property TFileCommentEvent OnFileComment = {read=FOnFileComment, write=FOnFileComment};
    __property TTickerEvent OnTicker = {read=FOnTicker, write=FOnTicker};
    __property TAfterCallBackEvent OnAfterCallBack ={read=FOnAfterCallBack, write=FOnAfterCallBack};
    __property TFileExtraEvent OnFileExtra={read=FOnFileExtra, write=FOnFileExtra};
    __property TTotalProgressEvent OnTotalProgress={read=FOnTotalProgress, write=FOnTotalProgress}; // new 1.73
    __property TItemProgressEvent OnItemProgress={read=FOnItemProgress, write=FOnItemProgress}; // new 1.73
    __property TZipStrEvent OnZipStr={read=FOnZipStr, write=FOnZipStr}; // new 1.73


    __property int BufSize={read=FBufSize, write=FBufSize, default=8192};
#ifndef NO_SPAN
		__property bool ConfirmErase = {read=FConfirmErase, write=FConfirmErase, default=true};
#if __BORLANDC__ > 1328		// BCB3=0x0530(1328)
		__property __int64 KeepFreeOnDisk1 = {read=FFreeOnDisk1, write=FFreeOnDisk1, default=0};
    __property __int64 KeepFreeOnAllDisks = {read=FFreeOnAllDisks, write=FFreeOnAllDisks, default =0};
		__property __int64 MaxVolumeSize = {read=FMaxVolumeSize, write=FMaxVolumeSize, default=0};
#else
    __property long KeepFreeOnDisk1 = {read=FFreeOnDisk1, write=FFreeOnDisk1, default=0};
		__property long MaxVolumeSize = {read=FMaxVolumeSize, write=FMaxVolumeSize, default=0};
    __property long KeepFreeOnAllDisks = {read=FFreeOnAllDisks, write=FFreeOnAllDisks, default =0};
#endif
		__property long MinFreeVolumeSize = {read=FMinFreeVolSize,write=FMinFreeVolSize,default=65536};
		__property TGetNextDiskEvent OnGetNextDisk = {read=FOnGetNextDisk, write=FOnGetNextDisk};
		__property TStatusDiskEvent OnStatusDisk = {read=FOnStatusDisk, write=FOnStatusDisk};
#endif
#ifndef NO_SFX
		__property SfxOpts SFXOptions = {read=FSFXOptions, write=FSFXOptions, default=SFXCheckSize};
		__property String	 SFXPath	= {read=FSFXPath,	write=FSFXPath,	nodefault};
		__property OvrOpts SFXOverWriteMode = {read=FSFXOverWriteMode, write=FSFXOverWriteMode, default=OvrConfirm};
		__property String	 SFXCaption = {read=FSFXCaption, write=FSFXCaption, nodefault};
		__property String	 SFXDefaultDir = {read=FSFXDefaultDir, write=FSFXDefaultDir,  nodefault};
		__property String	 SFXCommandLine = {read=FSFXCommandLine, write=FSFXCommandLine, nodefault};
		__property String  SFXMessage = {read=FSFXMessage, write=FSFXMessage, nodefault};
		__property TIcon  *SFXIcon = {read=FSFXIcon, write=SetSFXIcon, nodefault};
#endif
};

#pragma option -a.

#if __BORLANDC__ < 1344		// BCB4=0x540(1344)
 //-- template instantiations -------------------------------------------------
 template class ExtrOpts;
 template class AddOpts;
 template class SfxOpts;
 template class AddStoreExts;
#endif
}	/* EOF namespace ZipBuilder */

#if !defined(NO_IMPLICIT_NAMESPACE_USE)
	using namespace ZipBuilder;
#endif


/*
Changes for 1.73
  - From this release part of the history can be found at the top of each changed/new function
    Version, date and author and reason forchange are indicated for each function
Changes for version 1.72.2
  -Changed WriteSplit : proper handling of returned values from OnStatusDisk event
  -changed WriteSpan : if Result is not 0 (error) last file rename should not be executed
  -changed FindLastVolume: avoid illegal handle exception when not right disk in floppy and abort
  -FOF_NOERRORUI added in EraseFiles
Changes for version 1.72.1
  -Changed List,SetZipComment, to fix problems when NO_SPAN option used
  -Fixed bug, after performing list() on legal zipfile list() is called with non existing
   zip file we got InvalidHandle exception
Changes for version 1.72.0
  -Used new version numberscheme synchronised with ZipMaster
  -Bug fix on loading DLL's reported by Eric Engler 1/1/2003
  -New event TFileExtraEvent added will work with version 1.73 of ZiPDll
  -In events FileSize changed to unsigned same as in dlls
  -Bug fix for creation of MV archieve with spCompatNames, change last file in WriteSplit
  -Removed renaming of filename in AddExt
  -changed functions List checks Busy and if busy returns ErrCode
   Add, AddStreamToFile, Extract, Delete : same as List
  -moved the const int statements from zipbuilder.h to zipbuildefs.h because they
   prevented generation of precompiled headers in BCB
Changes for version 1.71
  - added version test on properties KeepFreeOnDisk1 and MaxVolumeSize for BCB3 they remain 'long'
    BCB3 does not have __int64 properties
  -Change function CheckForDisk(void) to CheckForDisk(bool writing)
  -Fixed Bug in ConvertZip when reading SFXoptions with MPU signature
  -Added Add options AddSave to use a temporary file in DLL during avoid corruption of original
  -Added new property ExtAddStoreSuffixes to add suffixes not in the set to be copied not compressed
  -Added new property set SpanOpts with spNoVolumeName, spCompatName
    spNoVolumeName : does not change Volume names of spanned disks uses multi volume filenames
    spCompatName : use filename type Archive.zXX where xx is partnumber and last part gets .zip
  -Changed method of writing EOC to floppies tooks long time
  -Extracting from multi volume archives is now possible
  -Recomposing archive from multi volume is possible with ReadSpan method
  -Avoid asking for last disk when not needed by using OnGetNextDiskevent and not showMessage
  -No request for disk if is first disk and already diskpresent
  -Bug fix in DiskFreeAndSize found by Russell Peters
  -Added events OnThick and OnAfterCallback to improve progress indication during Add operations
  -Added function FindLastVolume that handles looking for part/volume with central dir for
   spanned and multi volume archies
  -Added function CreateMVFileName to create multi volume file names
  -Fixed wrong DiskSeq numbers in WriteSplit with multivolume names

Changes for version 1.70
  -Added BufSize as property instead of const, made Date published property
	-Translated changes made in ZipMaster v1.70 by Russell Peters to "synchronize" both
	 projects, involved changes in functions:
	 - introduction of compiler flags NO_SPAN and NO_SFX to build light versions
	 - changes in Load/Unload Zip and Unzip DLL
	 - add functions GetZipDllpath GetUnzDllPath
   - new format function for floppy drives
	 - functions Rename, Delete, CopyyZippedFiles, ReadSpan, WriteSpan changed not to use class MDZD
	  Note : All new functions and major changes designed by Russell Peters
  -Added compiler flag NO_STREAM to leave streaming functions out
	-Added error messages for CopyZippedFiles and Rename on spanned archives
	-fixed error message inconsistencies and wrong cursor in SetZipComment and Rename
	-Changed SetZipComment to allow putting comment before in existing archive before
	 add is executed changes proposed by Russell Peters

Changes for version 1.60r by R. Aelbrecht Beta release 6/10/2002
		-Changes proposed by Russell Peters required to enable component to be buld on BCB6
    	- changes for unknown min/max macros
    	- changes for cast for int/__int64 stream ambiguities
		-Error mesage changed when Outfile not created proposed by Pedro Araujo, and added default
		 case on return from FormatDisk
		-Changed passing of password to Dll in extadd, deleted a non existing char array
		-Changed the errorNbr in OnMessage event
		-Changed function Rename to allow drive spec and to allow OEM chars in the file spec
		 same for CoppyZippedFiles, added function RemoveDriveSpec

⌨️ 快捷键说明

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