home *** CD-ROM | disk | FTP | other *** search
- unit CakDir;
- // Common Archiver Kit Experiment(CAKE)
- // Common Interface for Compression/Decompression components.
-
- //Copyright (C) Joseph Leung 2001 (lycj@yahoo.com)
- //
- //This library is free software; you can redistribute it and/or
- //modify it under the terms of the GNU Lesser General Public
- //License as published by the Free Software Foundation; either
- //version 2.1 of the License, or (at your option) any later version.
- //
- //This library is distributed in the hope that it will be useful,
- //but WITHOUT ANY WARRANTY; without even the implied warranty of
- //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- //Lesser General Public License for more details.
- //
- //You should have received a copy of the GNU Lesser General Public
- //License along with this library; if not, write to the Free Software
- //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- // ___________________________________________|
- // CAKE ver 1.0.30 |
- // lastupdate 11.03.2001 |
- // hIsToRy |
- // ___________________________________________|
- // |1.0.3 extract/list/test. |
- // |1.0.4 added zip stop function. |
- // |-.-.- added zip add function. |
- // |-.-.- added zip delete function. |
- // |-.-.- added filelist (html/txt). |
- // |1.0.5 added rs list function. |
- // |-.-.- added rs extr functions. |
- // |1.0.6 added zip sfx functions. |
- // |1.0.7 some code to fix directory. |
- // |1.0.8 added zip overwrite code. |
- // |1.0.9 New_Archive command. |
- // |1.0.10 Pk3 = Zip now. |
- // |1.0.11 Hotedit function. |
- // |-.-.-- added zip rename function. |
- // |-.-.-- Filters need USE_ARC now. |
- // |1.0.12 added arc add function. |
- // |1.0.13 Clear add list after add. |
- // |-.-.-- added arc delete function. |
- // |-.-.-- added arc overwrite code. |
- // |-.-.-- added zip sfx extractpath. |
- // |-.-.-- added get_total_size. |
- // |-.-.-- added get_selected_size. |
- // |1.0.14 Hotedit update check if file exist.|
- // |1.0.15 arc add now work without all dll. |
- // |-.-.-- (it will set the file type first.) |
- // |-.-.-- fixed onprogress. |
- // |1.0.16 fixed crash if not assign event. |
- // |1.0.17 new code on registry/inifiles. |
- // |-.-.-- simple showagain? and yesno dialog.|
- // |-.-.-- association code. |
- // |-.-.-- small fix on cab adding, |
- // |-.-.-- (require modify CAB32.pas to fix.) |
- // |-.-.-- line 60, 255, replace cmdline to |
- // |-.-.-- Fcmdline. |
- // |-.-.-- <No longer use that to load CAB |
- // |-.-.-- , So nevermind...> |
- // |-.-.-- it will nolonger add only 1 file. |
- // |-.-.-- updated DelZip1.6N(replace 1.6L). |
- // |1.0.18 Getassociatedprogram |
- // |-.-.-- Size in K, GetArcString, Cando. |
- // |1.0.19 Fix a bug in mask_add_selectedlist.|
- // |-.-.-- Runandwait, install, checkout. |
- // |-.-.-- added SHChangeNotify component. |
- // |-.-.-- minitor file system change. |
- // |1.0.20 Moved some item to CAKStrings.pas. |
- // |-.-.-- event for password/overwrite. |
- // |-.-.-- will work even unassigned. |
- // |-.-.-- modified FuncCheck const. |
- // |-.-.-- monitor registry change. |
- // |-.-.-- (check MonitorShowChanges) |
- // |-.-.-- Warning :required > 10mb of memory.|
- // |-.-.-- More if you modify it to check |
- // |-.-.-- Whats changed(hint: Check //ed var)|
- // |-.-.-- added function CreateShortCut. |
- // |1.0.21 Load & Decode UUE files. |
- // |-.-.-- (Thanks Marcus Wirth for tips) |
- // |-.-.-- (UUE add contain bug, dont use it!)|
- // |-.-.-- A working Find function. |
- // |-.-.-- Extract : archive in archives. |
- // |1.0.22 Loading Cab without cab32.dll. |
- // |-.-.-- Fix GrabDesktopPath. |
- // |-.-.-- CAKScript - Load_Script. |
- // |-.-.-- ^^^ Suggested extensions (*.AKS) |
- // |-.-.-- Converter - Archive_Convert |
- // |-.--.- Warning : Directory not supported. |
- // |-.-.-- Filename truncater. |
- // |-.-.-- Warning : Directory not supported. |
- // |-.-.-- added : GrabProgramPath. |
- // |-.-.-- Fix ArcOpenSupport, ArcAddSupport. |
- // |-.-.-- Copied UUE code to XXE/B64 code. |
- // |-.-.-- Fix MruList. |
- // |1.0.23 Pak, Wad Loading, Extracting |
- // |-.-.-- Disk spanner(Create .bat to unspan)|
- // |-.-.-- Disk imager, SFX to Zip |
- // |-.-.-- Backup registry to .reg file |
- // |-.-.-- new Add_Selected_List, faster |
- // |-.-.-- RsDir Add function completed. |
- // |-.-.-- added Crypto Zip Encrypt function. |
- // |-.-.-- added DeleteAllFiles function. |
- // |1.0.24 Updated reSource version 2.6. |
- // |-.-.-- support multiple %1% parameter. |
- // |-.-.-- SYNC command, removedrive. |
- // |-.-.-- isLocked command. |
- // |-.-.-- Customizable archive type(treatas).|
- // |-.-.-- new Properties. |
- // |-.-.-- Updated Capack version 1.36. |
- // |1.0.25 REN, RENDIR, MSG command. |
- // |-.-.-- zipdirRename |
- // |-.-.-- a fix for pak/wad loading. |
- // |1.0.26 CanAdd, CanExtract. |
- // |-.-.-- missed file: strconst.inc included.|
- // |1.0.27 Archive file size now working. |
- // |-.-.-- List_Mask_Archive speed improve =) |
- // |-.-.-- List_Cache_Archive |
- // |-.-.-- Fixed multi "%1%" in loading aks. |
- // |-.-.-- Fixed DelKeyInReg. |
- // |-.-.-- VersionControl(see qzip2). |
- // |-.-.-- Fixed adding masked folder to cab. |
- // |-.-.-- Fixed Ace wont crash when closing. |
- // |1.0.28 Cake Extension - let you customize |
- // |-.-.-- Cake to use dos-prompt archiver. |
- // |-.-.-- Fixed Batch Zip. |
- // |-.-.-- Fixed Pollfilelist |
- // |-.-.-- GenerateIndex - create index.. |
- // |-.-.-- Fixed Create dir in wrong loc(zip) |
- // |1.0.29 Fix Zip not adding subdirs. |
- // |-.-.-- Removed analysis because of bugs. |
- // |-.-.-- Included Floopy.pas and vwin32.pas.|
- // |-.-.-- Cab adding support dir now. |
- // |-.-.-- Fix Cab adding confirmation dialog.|
- // |1.0.30 Ace2 Extract support added. |
- // |-.-.-- Fixed Zip extract to root path. |
- // |-.-.-- New features : Create Thumbnail. |
- // |1.0.31 Fixed Cab Directory issue. |
- // |------------------------------------------|
-
-
- {$INCLUDE CAKDIR.INC} //Config, Read it before compile!
- {$IFDEF USE_ZIP}{$R ZipMsgUS.res}{$ENDIF} //ZipDir Res file
- interface
- uses
- CakStrings,
- Graphics,
- CakExt, {CakExtension}
- Cabinet,fci,fdi,fcntl, {Used for load cabinet}
- {TResource is used by Graphics & RsDir}
- {$IFDEF USE_ZIPR} ZipRepair, {$ENDIF}
- {$IFDEF USE_ZIP} ZipMstr, {$ENDIF}
- {$IFDEF USE_ACE} RTdunAce, {$ENDIF}
- {$IFDEF USE_ACE2} UNACEV2, {$ENDIF}
- {$IFDEF USE_ARC} Archives, {$ENDIF}
- {$IFDEF USE_ARC} Filters, {$ENDIF}
- {$IFDEF USE_ARC} CAB32, {$ENDIF}
- {$IFDEF USE_WINEXT} WinEx32, {$ENDIF}
- {$IFDEF USE_CZIP} EncryptIt, {$ENDIF}
- {$IFDEF USE_RS} ResourceCompUnit, {$ENDIF}
- {$IFDEF USE_RS} RsSupp, {$ENDIF}
- {$IFDEF USE_RS} ArchiveHeadersUnit,{$ENDIF}
- {$IFDEF USE_RS} FClasses, {$ENDIF}
- {$IFDEF USE_INDY} IdBaseComponent, {$ENDIF}
- {$IFDEF USE_INDY} IdCoder,IDGlobal, {$ENDIF}
- {$IFDEF USE_INDY} IdCoder3To4, {$ENDIF}
- {$IFDEF USE_SHCN} SHChangeNotify, {$ENDIF}
- {$IFDEF USE_PDF} PDFMaker, PMFonts, {$ENDIF}
- Windows, Messages, ShlObj, SysUtils, Classes, Controls, Forms, Dialogs,
- StdCtrls, Registry, Inifiles, Shellapi, Extctrls, FileCtrl, Masks, MAPI,
- Floppy,vwin32,Links;
-
- const
- MAJORVER = '1';
- MINORVER = '0';
- BUILD = '30';
-
- CAKVER = MAJORVER + '.'+ MINORVER + '.' + BUILD;
- DefaultTreatAsZip = '.ZIP .PK3 .EXE .JAR .WSZ .SIT';
- DefaultTreatAsRar = '.RAR';
- DefaultTreatAsCab = '.CAB';
- DefaultTreatAsLha = '.LHA .LZH';
- DefaultTreatAsArj = '.ARJ';
- DefaultTreatAsAce = '.ACE';
- DefaultTreatAsTar = '.TAZ .TAR';
- DefaultTreatAsTgz = '.TGZ .GZ .Z';
- DefaultTreatAsBz2 = '.BZ2 .TB2';
- DefaultTreatAsBza = '.BZA .GZA';
- DefaultTreatAsCzip = '.CZIP';
- DefaultTreatAsRs = '.RS';
- DefaultTreatAsYz1 = '.YZ1';
- DefaultTreatAsUue = '.UUE .UU .ENC';
- DefaultTreatAsXxe = '.XXE';
- DefaultTreatAsB64 = '.B64';
- DefaultTreatAsPak = '.PAK .WAD';
- DefaultTreatAsBel = '.BEL';
- DefaultTreatAsGcA = '.GCA';
- DefaultTreatAsAks = '.AKS';
-
- type
- supportType = (_Zip,_Rar,_Cab,_Arj,_Lha,_Tar,_Tgz,_Ace,_Bz2,_Bel,_Gca,_Bza,_Rs,_Czip,_Yz1,_Uue,_Xxe,_B64,_Pak,_Ext,_Aks,_WIT);
- filelisttype = (_Txt, _Htm,_Pdf,_Pdf2);
- sortbyType = (_FName, _FType, _FSize, _FPSize,_FCRC,_FRatio, _FDefPath, _FTime, _FArchive);
- cabmodetype = (_CFList,_CFExtract);
- addmodetype = set of (_refresh, _update, _move);
-
- TCOverEvent = procedure ( Sender : TObject; Filename : string;var overwrite : boolean ;var applytoall : boolean) of object;
- TCPwdEvent = procedure ( Sender : TObject; archive, filename : string; var newpassword : string) of object;
- TCMsgEvent = procedure( Sender: TObject; ErrCode: Integer; Message: String ) of object;
- TCProgEvent = procedure( Sender: TObject; Filename: String; FileSize: Longint; Completed : Longint ) of object;
- TCFoundEvent = procedure ( Sender: TObject; Filename: String; Filesize : integer) of object;
- TCCrytoEvent = procedure ( Sender : TObject; var key1, key2, key3 : integer) of object;
- Arctype = record
- _ARCname : string;
- _ARCtype : supporttype;
- _ARCsize : integer;
- _ARChaveinst,
- _ARChavecomm,
- _ARCneedpassword : boolean;
- _ARCTime : TDatetime;
- end;
- Regnodetype = record
- iskey : boolean;
- fullpath : string;
- keyname : string;
- {// valuetype : TRegDataType;
- dataS : String;
- dataES : ANSIString;
- dataI : integer;
- dataB : integer; //}
- subkey : TList;
- end;
- PRegnodetype = ^Regnodetype;
- Contenttype = record
- _FileIcon,_FileRatio, _Tag : integer;
- _FileSize,_FilePackedSize : Longint;
- _FileTime : TDatetime;
- _Filename,_Filetype,
- _FileCRC,_FileDefPath,_FileArchive : String;
- _Encrypted, _Selected : boolean;
- end;
- SfxOptionstype = record
- sfx_to : integer;
- sfx_message : string;
- sfx_commandline : string;
- sfx_caption : string;
- sfx_extractto : string;
- sfx_autorun : boolean;
- sfx_overwrite : boolean;
- end;
- ExtractOptionstype = record
- extr_to : string;
- extr_DirNames : boolean;
- extr_OverWrite : boolean;
- extr_ArcINArc : boolean;
- end;
- AddOptionstype = record
- add_to : integer;
- add_encrypt : string;
- add_SubDir : boolean;
- add_useencrypt : boolean;
- add_usepath : boolean;
- add_mode : addmodetype;
- add_hidden : boolean;
- add_filelist : boolean;
- add_files : TStrings;
- add_basedir : string;
- add_exclude : TStrings;
- add_dosformat : boolean;
- add_relative : boolean; //zip only!!
- end;
- FinderOptionstype = record
- af_targetname : TStrings;
- af_sourcedir : string;
- af_subdir : boolean;
- af_arcfilter : string;
- af_arctype : set of supporttype;
- af_containtext : string;
- end;
- Worktype = (_None, //Donothing
- _LoadContents, //List Archive
- _Extract, //Extract Archive
- _Test, //Test Archive
- _Add, //Add file to archive
- _Delete, //Delete file from archive
- _SFX, //Create Self extractables
- _CryptoZip
- );
-
- AVILTYPE = array[Worktype] of boolean;
-
- TCakDir = class(TComponent)
- private
- FOnOver : TCOverEvent;
- FOnPwd: TCPwdEvent;
- FOnMsg: TCMsgEvent;
- FOnProg: TCProgEvent;
- FOnFound: TCFoundEvent;
- FOnCryto: TCCrytoEvent;
- stopping : boolean;
- loadlines : boolean;
- Cabmode : cabmodetype;
- Cab_Extr_to : string;
-
- procedure doStop(Stopp : boolean);
- procedure Fillabout;
- procedure SetArchivetype(value : supportType);
- function GetArchivetype : supportType;
- function Process(processwhat : worktype) : boolean;
- function Compare(Item1, Item2: Contenttype; FSortforward : boolean; atype: Sortbytype): integer;
- procedure QuickSort(var Sortarray: array of Contenttype; size: integer;
- FSortforward : boolean; atype: Sortbytype);
- function GetARCtype1(archivename : string) : supporttype;
- {$IFDEF USE_WINEXT} function GetARCtype2(archivename : string) : supporttype; {$ENDIF}
-
- {$IFDEF USE_ZIP} function ProcessZIP(processwhat : worktype) : boolean; {$ENDIF}
- {$IFDEF USE_ZIP} procedure Load_ZIP_DLL; {$ENDIF}
- {$IFDEF USE_ZIP} procedure UNLoad_ZIP_DLL; {$ENDIF}
- {$IFDEF USE_ZIP} procedure ZipDirMessage(Sender: TObject; ErrCode: integer; Message: string); {$ENDIF}
- {$IFDEF USE_ZIP} procedure ZipDirProgress(Sender: TObject; ProgrType: ProgressType; Filename: string; FileSize: integer); {$ENDIF}
- {$IFDEF USE_ZIP} procedure ZipDirPwdErr(Sender: TObject; IsZipAction: Boolean; var NewPassword: String; ForFile: String; var RepeatCount: Cardinal; var Action: TPasswordButton); {$ENDIF}
- {$IFDEF USE_ZIP} procedure ZipDirExtrOver(Sender: TObject; ForFile: String; Older: Boolean; var DoOverwrite: Boolean; DirIndex: Integer); {$ENDIF}
-
- {$IFDEF USE_ACE} function ProcessACE(processwhat : worktype) : boolean; {$ENDIF}
- {$IFDEF USE_ACE} procedure Load_ACE_DLL; {$ENDIF}
- {$IFDEF USE_ACE} procedure UNLoad_ACE_DLL; {$ENDIF}
- {$IFDEF USE_ACE} procedure AceDirList(Sender: TObject; eFile: TACEHeaderData; Result: Boolean); {$ENDIF}
- {$IFDEF USE_ACE} procedure AceDirError(Sender: TObject; Error: Integer); {$ENDIF}
- {$IFDEF USE_ACE} procedure AceDirExtracting(Sender: TObject; eFile: TACEHeaderData); {$ENDIF}
- {$IFDEF USE_ACE2} function CallAceInitDll : integer; {$ENDIF}
- {$IFDEF USE_ACE2} procedure Ace2HandleError(ErrNo : integer); {$ENDIF}
-
- {$IFDEF USE_ARC} function ProcessARC(processwhat : worktype) : boolean; {$ENDIF}
- {$IFDEF USE_ARC} procedure Load_ARC_DLL; {$ENDIF}
- {$IFDEF USE_ARC} procedure UNLoad_ARC_DLL; {$ENDIF}
- {$IFDEF USE_ARC} procedure ArcDirProgress( Sender:TObject;State:Integer;lpEis:LPEXTRACTINGINFOEX;var Abort: Boolean ); {$ENDIF}
- {$IFDEF USE_ARC} procedure ARCHandleError(code : integer); {$ENDIF}
-
- function ProcessEXT(processwhat : worktype) : boolean;
- procedure Load_EXT_DLL;
- procedure UnLoad_EXT_DLL;
- procedure SetScriptPath(path : string);
- function translatetype(aworktype : worktype) : worktypeex;
-
- {$IFDEF USE_CZIP} function ProcessCZIP(processwhat : worktype) : boolean; {$ENDIF}
- procedure ProcessAKS(processwhat : worktype);
- function ProcessPAK(processwhat : worktype) : boolean;
- function ProcessCAB(processwhat : worktype) : boolean;
- procedure Load_CAB_DLL;
- procedure UNLoad_CAB_DLL;
- procedure CabRCopyFile(Sender: TObject; const FileName: String; UncompressedSize: Integer; Date, Time,
- Attribs: Smallint; var Action: TFileCopyAction;
- var DestFileHandle: Integer);
- procedure CabRDirCloseCopied(Sender: TObject;
- const FileName: String; FileHandle: Integer; Date, Time,
- Attribs: Smallint; FolderIndex: Integer; Execute: Boolean;
- var Abort: Boolean);
- procedure CabWFilePlaced(Sender: TObject; var CabParameters: TCCAB; const FileName: String; FileLength: Integer;
- Continuation: Boolean; var AbortProcessing: Boolean);
- procedure CabRNextCab(Sender: TObject;
- const NextCabinetName, NextCabinetDisk: String; var CabinetPath: String;
- ErrorIndication: TFDIERROR; var Abort: Boolean);
-
- {$IFDEF USE_RS} function ProcessRS(processwhat : worktype) : boolean; {$ENDIF}
- {$IFDEF USE_RS} procedure Load_RS_DLL; {$ENDIF}
- {$IFDEF USE_RS} procedure UNLoad_RS_DLL; {$ENDIF}
- {$IFDEF USE_RS} Procedure RsDirAddLog(Sender: TObject; s: String); {$ENDIF}
- {$IFDEF USE_RS} Procedure RsDirCDChange(Sender: TObject); {$ENDIF}
-
- {$IFDEF USE_INDY} function ProcessUUE(processwhat : worktype) : boolean; {$ENDIF}
- {$IFDEF USE_INDY} function ProcessB64(processwhat : worktype) : boolean; {$ENDIF}
- {$IFDEF USE_INDY} function ProcessXXE(processwhat : worktype) : boolean; {$ENDIF}
-
- {$IFDEF USE_SHCN}procedure CNOnAttrib(Sender: TObject; Flags: Cardinal;Path1: String);{$ENDIF}
- {$IFDEF USE_SHCN}procedure CNOnCreate(Sender: TObject; Flags: Cardinal;Path1: String);{$ENDIF}
- {$IFDEF USE_SHCN}procedure CNOnDelete(Sender: TObject; Flags: Cardinal;Path1: String);{$ENDIF}
- {$IFDEF USE_SHCN}procedure CNOnNewDir(Sender: TObject; Flags: Cardinal;Path1: String);{$ENDIF}
- {$IFDEF USE_SHCN}procedure CNOnRename(Sender: TObject; Flags: Cardinal;Path1, path2: String);{$ENDIF}
- {$IFDEF USE_SHCN}procedure CNOnRmDir(Sender: TObject; Flags: Cardinal;Path1: String);{$ENDIF}
- {$IFDEF USE_SHCN}procedure CNOnUpdateDir(Sender: TObject; Flags: Cardinal;Path1: String);{$ENDIF}
- {$IFDEF USE_SHCN}procedure CNOnUpdateItem(Sender: TObject; Flags: Cardinal;Path1: String);{$ENDIF}
-
- procedure T1Ontimer(Sender : TObject);
- procedure PlainDialog;
- procedure FreePlainDialog;
- Function ExecInf( Var Path, Param: String ): Cardinal;
- procedure ExecReg(Var Path : String);
- function ArcOpenSupport : string;
- function ArcAddSupport : string;
- function MakeRegnode(rootkey : HKEY; path : ANSIstring) : Tlist;
- procedure CleanRegnode(alist : TList);
- procedure AddRegnode(Rootkey : Hkey; alist : TList;var astring : TStrings;key, subkey : string);
- procedure CompareRegnode(rootkey :HKEY; list1,list2 : TList; var astring : TStrings; key,subkey : string);
- function InitContentType : Contenttype;
-
- protected
- public
- {$IFDEF USE_ZIP} Zipdir : TZipMaster; {$ENDIF}
- {$IFDEF USE_ACE} Acedir : TdACE; {$ENDIF}
- {$IFDEF USE_ARC} Arcdir : TArchiveFile; {$ENDIF}
- {$IFDEF USE_RS } Rsdir : TResource; {$ENDIF}
- {$IFDEF USE_SHCN}SHCN : TSHChangeNotify; {$ENDIF}
- CabWDir: TCabinetWriter;
- CabRDir: TCabinetReader;
- CabFH : TStreamCabinetFileHandler;
- {$IFDEF USE_SHCN}HISTORY: TStringList; {$ENDIF}
-
- CakExt : TCakExt;
- CakExtLogFile : string;
- TreatasExt : string;
-
- Timer1 : TTimer;
-
- AsZip, AsRar, AsCab, AsArj, AsLha, AsTar, AsTgz,
- AsAce, AsBz2, AsBel, AsGca, AsBza, AsRs, AsCZip,
- AsYz1, AsUue, AsXxe, AsB64, AsPak, AsAks : string;
-
- ImageS: TImageList;
- ImageL: TImageList;
- FileType, FileExt, DirectoryList, Abouttext, MRUList, NewDirList, ScriptParam : TStringlist;
- MaxMRU : integer;
- Total_Archive : integer;
- Total_Contents, Fullcontentcount : integer;
- key1,key2,key3 : integer;
- leadchar, Temppath : String;
- scriptvar1 : string;
- password : string;
-
- Archive_List : array of Arctype;
- Archive_Contents, temp_Contents, Full_Contents : array of Contenttype;
-
- processfrom, processto, processing : integer;
- Extractoptions : ExtractOptionsType;
- AddOptions : AddOptionsType;
- sfxOptions : SfxOptionsType;
- FinderOptions : FinderOptionsType;
-
- cancelwait,terminaterun : boolean;
-
- versioncontrol : boolean;
-
- constructor Create( AOwner: TComponent ); override;
- destructor Destroy; override;
-
- //Archive List functions
- procedure Set_Archive_List(filename : string);
- function Get_Archive_Name : string;
- procedure Clear_Archive_List;
- function Add_Archive_List(filename : string) : integer;
- procedure Append_Archive_List(filename : string; appendto : integer);
- procedure Sort_Archive_List(accending : boolean; atype: Sortbytype);
- function Get_Total_Size : Longint;
- {$IFDEF USE_WINEXT} procedure GetFileType(filename : string; var info1,info2, info3 : string); {$ENDIF}
-
- //Command
- procedure List_Archive(arcfrom,arcto : integer);
- procedure List_Cache_Archive;
- procedure List_Mask_Archive(mask : string; arcfrom,arcto : integer; showonlythatdir : boolean);
- procedure Extract_Archive(arcfrom, arcto : integer);
- procedure Test_Archive(arcfrom,arcto : integer);
- procedure Delete_Archive(arcfrom,arcto : integer);
- procedure New_Archive(filename : string);
- procedure Load_Script(script : Tstrings);
- procedure Archive_Convert(filename : string; totype : supporttype);
- procedure Filename_Truncate(arcname : string);
- procedure Extract;
- procedure Test;
- procedure Delete;
- procedure Add;
- procedure SFX;
- function AskOverwrite(forfile : string) : boolean;
- {$IFDEF USE_ZIP} procedure SFX2ZIP(SFXname : string); {$ENDIF}
- {$IFDEF USE_CZIP} procedure CrytoZip; {$ENDIF}
-
- procedure Find;
- procedure FindStop;
- procedure BatchAdd(afilelist : TStrings; archivetype : supporttype);
- function Checkout(arc : integer;openit : boolean) : string;
- procedure Install(filename : string; arc : integer);
- procedure HotEdit(filename : string; arc : integer);
- function Cando(atype : supporttype;awork : worktype) : boolean;
- function CanAdd : boolean;
- function CanExtract : boolean;
- procedure Filelist(fltype : filelisttype;filename : string; arcfrom, arcto : integer);
- {$IFDEF USE_ZIP} procedure Zipdirrenamedir(SourceName, DestName: string); {$ENDIF}
- {$IFDEF USE_ZIP} procedure Zipdirrename(SourceName, DestName: string); {$ENDIF}
- {$IFDEF USE_ZIPR} procedure repairZip(SourceName, DestName : string); {$ENDIF}
-
- //Selected List function
- procedure Clear_Selected_List;
- procedure Add_Selected_List(filename, archivename : string); overload;
- procedure Add_Selected_List(filename : tstrings; archivename : string); overload;
- procedure Add_All_Selected_List;
- procedure Mask_Add_Selected_List(FileMasks, Filearchive: string);
- function Get_Selected_Count(ForArchive : string) : integer; overload;
- function Get_Selected_Count : integer; overload;
- function Get_Selected_Size : Longint;
- function Get_Selected_CompSize : Longint;
- function Get_Top_Selected : string;
-
- //Archive Content function
- function Get_Archive_Code(filearchive, filename : string) : integer;
-
- //Add List function
- procedure Clear_Add_List;
-
- //Path Grabbing
- function GrabDesktopPath : string;
- function GrabProgramPath : string;
- function GrabCurrentPath : string;
- function GrabTempPath : string;
- function GrabSystemPath : string;
- function GrabWindowPath : string;
- function GrabMydocuPath : string;
-
- //Archive related function
- procedure Thumbnail(Filename : string; cellHeight, cellWidth : Integer);
- //Others
- function CalcFolderSize(const aRootPath: string): Int64;
- procedure MakeDirectory(dirname: string);
- function appendSlash(input : string) : string;
- function removeSlash(input : string) : string;
- function modifyslash(input : string) : string; overload;
- function modifyslash(input : string;fromm,tto : char) : string; overload;
- function removefileext(input : string) : string;
- function removedrive(input : string) : string;
- function Returnicontype(filename : string) : integer;
- procedure reiniticons;
- function GetarcString(atype : supporttype) : string;
- function GetarcStringFull(atype : supporttype) : string;
- function GetarcStringFilter(atype : supporttype) : string;
- function sizeinK(size: int64): string;
- procedure run(programpath,Programparam : string);
- procedure runwww(wwwpath : string);
- procedure runandwait(programpath,Programparam : string);
- function isharddrive(drive : char) : boolean;
- function iscdrom(drive : char) : boolean;
- function isfloppy(drive : char) : boolean;
- procedure Explorefolder(folder : string);
- function newtemppath : string;
- {$IFDEF USE_SHCN}procedure MonitorStart;{$ENDIF}
- {$IFDEF USE_SHCN}function MonitorShowChanges : TStrings;{$ENDIF}
- {$IFDEF USE_SHCN}procedure MonitorStop; {$ENDIF}
- procedure SendMail(Subject, Mailtext, FromName, FromAdress, ToName, ToAdress, AttachedFileName, DisplayFileName: string; ShowDialog: boolean);
- function CreateShortcut(linkfilename,filepath : string) : boolean;
- function found(filename : string) : boolean;
- function SubDirList(dir : string) : TStrings;
- function GetARCtype(archivename : string) : supporttype;
- function DiskSpan(source, target : string; disksize : longint; MakeBatch : boolean) : integer;
- procedure DiskUnSpan(filename : string);
- function DiskMakeImage(drive : integer; filename : string) : boolean;
- function DiskWriteImage(drive : integer; filename : string) : boolean;
- function RegListsubkey(RKey : HKey; KeyPath : string) : TStrings;
- function RegListVal(RKey : HKey; KeyPath : string) : TStrings;
- procedure RegBackup(RKey : HKey; KeyPath, Value : string;filename : string);
- function rkeyname(rootkey :HKEY) : string;
- function name2rkey(key : string) : HKey;
- function DeleteAllFiles(FilesOrDir: string): boolean;
- procedure SetDefaultTreasAs;
- function isLocked(filename : string) : boolean;
- function GetFileSize(const FileName: String): Int64;
-
- //Registry support features
- function GetvalInReg(RKey : HKey; KeyPath : string; Valname : string) : string;
- procedure SetValInReg(RKey: HKey; KeyPath: string; ValName: string; NewVal: string);
- procedure DelValInReg(RKey: HKey; KeyPath: string; Key : string);
- procedure DelKeyInReg(RKey: HKey; KeyPath: string);
- function pollfilelist(maskedname : string; subdir : boolean) : tstrings;
- procedure GenerateIndex(path : string; masks : tstrings; Indexfilename, Contentfilename : string);
-
- //Associating
- procedure AssociateProgram(ext,path,icon : string);
- procedure UNAssociateProgram(ext : string);
- function GetAssociatedProgram(ext : string) : string;
- procedure refreshicon;
-
- //INI support features
- function GetvalInIni(filename : string; section : string; key : string; default : string) : string;
- procedure SetValInIni(filename : string; section : string; key, value : string);
-
- //Simple dialogs
- procedure RegAskShowAgainDialog(dcaption, Msg : string; Path, key : string);
- procedure IniAskShowAgainDialog(dcaption, Msg : string; Filename, section, key : string);
- function ShowAgainDialog(dcaption, msg : string) : boolean;
-
- procedure RegYesNoAskShowAgainDialog(dcaption, Msg : string; Path, section, key : string;var yesno : boolean);
- procedure IniYesNoAskShowAgainDialog(dcaption, Msg : string; Filename, Product, section, key : string;var yesno : boolean);
- function YesNoShowAgainDialog(dcaption,msg : string; var yesno : boolean) : boolean;
-
- published
- property OnCMessage :TCMsgEvent read FOnMsg write FOnMsg;
- property OnCProgress:TCProgEvent read FOnProg write FOnProg;
- property OnCArchiveFound:TCFoundEvent read FOnFound write FOnFound;
- property OnCOverwrite : TCOverEvent read FOnOver write FOnOver;
- property OnCPassword : TCPwdEvent read FOnPwd write FOnPwd;
- property OnCCrytoEvent : TCCrytoEvent read FOnCryto write FOnCryto;
-
- property ScriptShowLoadingLines : boolean read loadlines write loadlines default true;
-
- property TreatAsZip : string read AsZip write AsZip;
- property TreatAsRar : string read AsRar write AsRar;
- property TreatAsCab : string read AsCab write AsCab;
- property TreatAsArj : string read AsArj write AsArj;
- property TreatAsLha : string read AsLha write AsLha;
- property TreatAsTar : string read AsTar write AsTar;
- property TreatAsTgz : string read AsTgz write AsTgz;
- property TreatAsAce : string read AsAce write AsAce;
- property TreatAsBz2 : string read AsBz2 write AsBz2;
- property TreatAsBel : string read AsBel write AsBel;
- property TreatAsGca : string read AsGca write AsGca;
- property TreatAsBza : string read AsBza write AsBza;
- property TreatAsRs : string read AsRs write AsRs;
- property TreatAsCzip : string read AscZip write AscZip;
- property TreatAsYz1 : string read AsYz1 write AsYz1;
- property TreatAsUue : string read AsUue write AsUue;
- property TreatAsXxe : string read AsXxe write AsXxe;
- property TreatAsB64 : string read AsB64 write AsB64;
- property TreatAsPak : string read AsPak write AsPak;
- property TreatAsAks : string read AsAks write AsAks;
-
- property ArchiveName : string read Get_Archive_Name write Set_Archive_List;
- property ArchiveType : supportType read GetArchiveType write SetArchiveType default _WIT;
- property ExtractTo : string read ExtractOptions.extr_to write ExtractOptions.extr_to;
- property ExtractUsepath : boolean read ExtractOptions.extr_Dirnames write ExtractOptions.extr_Dirnames default True;
- property ExtractOverwrite : boolean read ExtractOptions.Extr_Overwrite write ExtractOptions.extr_Overwrite default False;
-
- property Addmode : addmodetype read AddOptions.add_mode write AddOptions.add_mode;
- property Addpassword : string read AddOptions.add_encrypt write AddOptions.add_encrypt;
- property Adduseencrypt : boolean read AddOptions.add_useencrypt write AddOptions.add_useencrypt default False;
- property Addusepath : boolean read AddOptions.add_usepath write AddOptions.add_usepath default True;
- property Addsubdir : boolean read AddOptions.add_subdir write AddOptions.add_subdir default True;
- property Addfiles : tstrings read AddOptions.add_files write AddOptions.add_files;
- property AddBaseDir : string read AddOptions.add_basedir write AddOptions.add_basedir;
- property AddExclude : tstrings read AddOptions.add_exclude write AddOptions.add_exclude;
-
- property CakExtScriptPath : string write SetScriptPath;
- property Stop : boolean read stopping write doStop;
- property About : TStringlist read Abouttext;
- end;
-
- TFinder = class(TThread)
- private
- FOnFound : TCFoundEvent;
- FOption : FinderOptionstype;
- CakDir1 : TCakDir;
- procedure Search(dir : string);
- protected
-
- public
- constructor Create(Createsuspended: boolean);
- procedure Execute; override;
- destructor Destroy; override;
- published
- property FinderOption : FinderOptionstype read FOption write FOption;
- property OnCArchiveFound:TCFoundEvent read FOnFound write FOnFound;
- end;
-
-
- procedure Register;
- const T = True; F = False;
- FuncCheck :
- array[supporttype,worktype] of boolean =
- ((T,T,T,T,T,T,T,T), (T,T,T,T,F,F,F,F), {_Zip,_Rar}
- (T,T,T,T,T,F,F,F), (T,T,T,T,F,F,F,F), (T,T,T,T,T,T,T,F), {_Cab,_Arj,_Lha}
- (T,T,T,T,T,T,F,F), (T,T,T,T,T,T,F,F), (T,T,T,T,F,F,F,F), {_Tar,_Tgz,_Ace}
- (T,T,T,T,T,T,F,F), (T,T,T,T,F,F,F,F), (T,T,T,T,F,F,F,F), {_Bz2,_Bel,_Gca}
- (T,T,T,T,T,T,F,F), (T,T,T,F,T,T,F,F), (T,T,T,F,F,F,F,F), {_Bza,_Rs,_Czip}
- (T,T,T,F,T,F,F,F), (T,T,T,F,F,F,F,F), (T,T,T,F,F,F,F,F), {_Yz1,_Uue,_Xxe}
- (T,T,T,F,F,F,F,F), (T,T,T,F,F,F,F,F), (T,F,F,F,F,F,F,F), {_B64,_Pak,_Ext}
- (T,T,T,F,F,F,F,F), (F,F,F,F,F,F,F,F));{_Aks,_WIT}
- {None,LoadContents,Extract,Test,Add,Delete,Sfx,CrytoZip}
-
- var processed_files : integer;
- TotalProgress : Longint;
- Total_Unpacked, Totalsize : longint;
- overwriteall : integer;
- lastname : string;
- aform : TForm;
- aCheckbox : TCheckbox;
- aLabel : TStaticText;
- A_HKCU,A_HKLM : TList;
- aFinder : TFinder;
- stopprocess : boolean;
- Ace2Msg : string;
- Ace2Code : integer;
- implementation
-
- constructor TFinder.Create(Createsuspended: boolean);
- begin
- inherited Create(CreateSuspended);
- CakDir1 := TCakDir.Create(nil);
- FreeOnTerminate := True;
- end;
- destructor TFinder.Destroy;
- begin
- CakDir1.free;
- inherited Destroy;
- end;
-
- function TCakdir.GetFileSize(const FileName: String): Int64;
- var
- myFile: THandle;
- myFindData: TWin32FindData;
- begin
- Result := 0;
- myFile := FindFirstFile(PChar(FileName), myFindData);
- if myFile <> INVALID_HANDLE_VALUE then
- begin
- Windows.FindClose(myFile);
- Result := Int64(myFindData.nFileSizeHigh) shl Int64(32) +
- Int64(myFindData.nFileSizeLow);
- end;
- end;
-
- procedure TFinder.Search(dir : string);
- var
- sr: TSearchRec;
- k: string;
- FileAttrs,i,j : integer;
- aStrings : TStrings;
- alist : tstrings;
- begin
- alist := tstringlist.create;
- alist.commatext := FOption.af_arcfilter;
- for j := 0 to alist.count -1 do
- begin
- k := CakDir1.appendslash(dir) + alist.strings[j];
- FileAttrs := 0;
- FileAttrs := FileAttrs and faAnyFile;
-
- if FindFirst(k , FileAttrs, sr) = 0 then
- begin
- if fileexists(CakDir1.appendslash(dir) + sr.Name) then
- begin
- CakDir1.Set_Archive_List(CakDir1.appendslash(dir) + sr.name);
- CakDir1.Total_Contents := 0;
- if CakDir1.Cando(CakDir1.GetARCtype(CakDir1.appendslash(dir) + sr.Name),_LoadContents) then
- CakDir1.List_Archive(0,0);
- if CakDir1.Total_Contents > 0 then
- For i := 0 to FOption.af_targetname.Count - 1 do
- if CakDir1.Found(FOption.af_targetname.strings[i]) then
- FOnFound(nil,dir + sr.name, sr.Size);
- end;
- while (FindNext(sr) = 0) and not terminated do
- if fileexists(CakDir1.appendslash(dir) + sr.Name) then
- begin
- CakDir1.Set_Archive_List(CakDir1.appendslash(dir) + sr.name);
- CakDir1.Total_Contents := 0;
- if CakDir1.Cando(CakDir1.GetARCtype(CakDir1.appendslash(dir) + sr.Name),_LoadContents) then
- CakDir1.List_Archive(0,0);
- For i := 0 to FOption.af_targetname.Count - 1 do
- if CakDir1.Found(FOption.af_targetname.strings[i]) then
- FOnFound(nil,dir + sr.name, sr.size);
- end;
- FindClose(sr);
- end;
- end;
- alist.free;
-
- Application.ProcessMessages;
- if FOption.af_subdir then
- begin
- aStrings := CakDir1.SubDirList(dir);
- if aStrings.count > 0 then
- For i := 0 to astrings.count -1 do
- if not terminated then
- begin
- Search(aStrings.strings[i]);
- Application.ProcessMessages;
- FOnFound(nil,CakDir1.Appendslash(aStrings.strings[i]),0);
- end;
- aStrings.free;
- end;
- end;
-
- procedure TFinder.Execute;
- begin
- if assigned(FOnFound) then
- begin
- Search(FOption.af_sourcedir);
- FOnFound(nil,'*COMPLETED*',-1);
- end else
- Showmessage('Error : Unassigned found event');
- end;
-
- constructor TCakDir.Create( AOwner: TComponent );
- begin
- inherited Create( AOwner );
-
- ImageS := TImageList.Create(self);
- ImageS.Width := 16;
- ImageS.Height:= 16;
- ImageL := TImageList.Create(self);
- ImageL.Width := 32;
- ImageL.Height:= 32;
- temppath := grabtemppath;
- Timer1 := TTimer.create(self);
- FileType := TStringList.Create( );
- FileExt := TStringList.Create( );
- NewDirList := TStringList.Create( );
- DirectoryList := TStringList.Create();
- DirectoryList.Sorted := true;
- MRUList := TStringList.Create();
- ExtractOptions.extr_ArcINArc := FALSE;
- AddOptions.add_exclude := TStringList.Create();
- AddOptions.add_files := TStringList.Create();
- ScriptParam := TStringList.Create();
- FinderOptions.af_targetname := TStringList.Create();
- Abouttext := TStringList.Create();
- Fillabout;
- Timer1.OnTimer := T1OnTimer;
- Timer1.Interval := 1000;
- Timer1.Enabled := False;
- processfrom := -1;
- processto := -1;
- MAXMRU := 9;
- AddOptions.add_files.Clear;
- leadchar := 'CAK.';
- scriptvar1 := '';
- Tag := strtointdef(MINORVER,0);
- SetDefaultTreasAs;
- versioncontrol := false;
- end;
- destructor TCakDir.Destroy;
- begin
- ImageS.Free;
- ImageL.Free;
- FileType.Free;
- FileExt.Free;
- Timer1.Free;
- Abouttext.free;
- MRUList.free;
- Scriptparam.free;
- AddOptions.add_files.Free;
- AddOptions.add_exclude.Free;
- NewDirList.free;
- FinderOptions.af_targetname.Free;
- DirectoryList.Free;
- UNLoad_CAB_DLL;
- {$IFDEF USE_ZIP} UNLoad_ZIP_DLL; {$ENDIF}
- {$IFDEF USE_ACE} UNLoad_ACE_DLL; {$ENDIF}
- {$IFDEF USE_ARC} UNLoad_ARC_DLL; {$ENDIF}
- {$IFDEF USE_RS} UNLoad_RS_DLL; {$ENDIF}
- UNLoad_EXT_DLL;
- inherited Destroy;
- end;
- function TCakDir.InitContenttype : contenttype;
- var content : contenttype;
- begin
- with content do
- begin
- _FileIcon := 0;
- _FileRatio := 0;
- _Tag := 0;
- _FileSize := 0;
- _FilePackedSize := 0;
- _FileTime := 0;
- _Filename := '';
- _Filetype := '';
- _FileCRC := '';
- _FileDefPath := '';
- _FileArchive := '';
- _Encrypted := false;
- _Selected := false;
- end;
- Result := content;
- end;
-
- procedure TCakdir.Fillabout;
- begin
- Abouttext.add(ABOUTSTR);
-
- end;
- function TCakdir.modifyslash(input : string) : string;
- var i : integer;
- k : string;
- begin
- k := input;
- for i := 0 to length(k) do
- if k[i] = '/' then k[i] := '\';
- result := k;
- end;
-
- function TCakdir.modifyslash(input : string;fromm,tto : char) : string;
- var i : integer;
- k : string;
- begin
- k := input;
- for i := 0 to length(k) do
- if k[i] = fromm then k[i] := tto;
- result := k;
- end;
-
- function TCakDir.appendSlash(input : string) : string;
- begin
- if length(input) > 0 then
- if input[Length(input)] = '\' then
- result := input else
- result := input + '\' else
- result := input;
- end;
-
- function TCakDir.removeSlash(input : string) : string;
- begin
- if input[Length(input)] = '\' then
- result := Copy(input,0,length(input) -1) else
- result := input;
- end;
-
- function TCakdir.removefileext(input : string) : string;
- var
- I: Integer;
- begin
- I := LastDelimiter('.\:', input);
- if (I > 0) and (input[I] = '.') then
- Result := Copy(input, 0, i-1) else
- Result := input;
- end;
-
- function TCakdir.removedrive(input : string) : string;
- var
- I: Integer;
- begin
- I := pos(':\', input);
- if (I > 0) and (input[I] = ':') then
- Result := Copy(input, I+2, length(input) -3) else
- Result := input;
- end;
-
- procedure TCakDir.T1Ontimer(Sender : TObject);
- begin
- Application.ProcessMessages;
- end;
-
- procedure TCakDir.doStop(Stopp : boolean);
- begin
- stopping := stopp;
- stopprocess := stopp;
- if Total_Archive > 0 then
- Case Archive_List[processfrom]._ARCtype of
- _ZIP : Zipdir.Cancel := true;
- end;
- end;
-
- procedure TCakDir.Add_All_Selected_List;
- var i : integer;
- begin
- for i := 0 to Total_Contents -1 do
- Archive_Contents[i]._Selected := true;
- end;
-
- procedure TCakDir.Clear_Selected_List;
- var i : integer;
- begin
- for i := 0 to Total_Contents -1 do
- Archive_Contents[i]._Selected := false;
- end;
-
- procedure TCakDir.Clear_Add_List;
- begin
- addoptions.add_files.clear;
- end;
- procedure TCakDir.Add_Selected_List(filename, archivename : string);
- var i : integer;
- begin
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._FileName = Extractfilename(filename) then
- if Archive_Contents[i]._FileArchive = archivename then
- if Archive_Contents[i]._FileDefpath = Extractfilepath(filename) then
- begin
- Archive_Contents[i]._Selected := True;
- end;
- end;
-
- procedure TCakDir.Add_Selected_List(filename : tstrings; archivename : string);
- var i : integer;
- begin
- for i := 0 to Total_Contents -1 do
- with Archive_Contents[i] do
- if not _Selected then
- if _FileArchive = archivename then
- if filename.IndexOf(_FileDefpath + _Filename) <> -1 then
- _Selected := True;
- end;
-
- procedure TCakDir.Mask_Add_Selected_List(FileMasks, Filearchive: string);
- var
- i: integer;
- AMask: TMask;
- begin
- AMask := TMask.Create(FileMasks);
- if Total_Archive <= 0 then exit;
- for i := 0 to Total_Contents - 1 do
- with Archive_Contents[i] do
- if AMask.Matches(_Filedefpath + _Filename) then
- if (Archive_Contents[i]._Filearchive = Filearchive) or (Filearchive = '') then
- begin
- Archive_Contents[i]._Selected := True;
- end;
- AMask.Free;
- end;
- function TCakdir.Get_Selected_Count(ForArchive : string) : integer;
- var i : integer;
- begin
- Result := 0;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- if Archive_Contents[i]._FileArchive = ForArchive then
- Inc(Result);
-
- end;
-
- function TCakDir.Get_Selected_Count : integer;
- var i : integer;
- begin
- Result := 0;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- Inc(Result);
- end;
-
- function TCakDir.Get_Selected_Size : Longint;
- var i : integer;
- begin
- Result := 0;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- Inc(Result, Archive_Contents[i]._FileSize);
- if Result = 0 then
- Result := -1;
- end;
-
- function TCakDir.Get_Selected_CompSize : Longint;
- var i : integer;
- begin
- Result := 0;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- Inc(Result, Archive_Contents[i]._Filepackedsize);
- if Result = 0 then
- Result := -1;
- end;
-
- function TCakDir.Get_Total_Size : Longint;
- var i : integer;
- begin
- Result := 0;
- for i := 0 to Total_Contents -1 do
- Inc(Result, Archive_Contents[i]._FileSize);
- if Total_Contents = 0 then Result := -1; //Prevent crash...
- end;
-
- procedure TCakDir.List_Mask_Archive(mask : string; arcfrom,arcto : integer; showonlythatdir : boolean);
- var i : integer;
- amask : TMask;
- count : integer;
- begin
- aMask := TMask.Create(mask);
- //List_Archive(arcfrom,arcto);
- Archive_Contents := Full_Contents;
- total_contents := Fullcontentcount;
- setlength(temp_contents,total_contents);
- count := -1;
- For i := Total_Contents -1 downto 0 do
- With Archive_Contents[i] do
- if amask.Matches(_Filedefpath + _Filename) then
- if ((not showonlythatdir) or (uppercase(_Filedefpath) = uppercase(extractfilepath(Mask) ))) then
- begin
- inc(count);
- temp_contents[count] := Archive_Contents[i];
- end;
-
- Total_contents := count + 1;
- SetLength(Archive_Contents,Total_contents);
- Archive_contents := temp_contents;
- { for i := 0 to count do
- Archive_contents[i] := temp_contents[i];}
-
-
- end;
-
- procedure TCakDir.List_Cache_Archive;
- begin
- Total_contents := Fullcontentcount;
- Archive_Contents := Full_Contents;
- end;
-
- procedure TCakDir.List_Archive(arcfrom,arcto : integer);
- begin
- if Total_Archive = 0 then exit;
- processfrom := arcfrom;
- processto := arcto;
- Process(_LoadContents);
- end;
-
- procedure TCakDir.Extract_Archive(arcfrom, arcto : integer);
- begin
- if Total_Archive = 0 then exit;
- if not directoryexists(ExtractOptions.extr_to) then
- MakeDirectory(ExtractOptions.extr_to);
-
- ExtractOptions.extr_to := AppendSlash(ExtractOptions.extr_to);
- processfrom := arcfrom;
- processto := arcto;
- Process(_Extract);
- end;
-
- procedure TCakDir.Extract;
- begin
- if Total_Archive = 0 then exit;
- if not directoryexists(ExtractOptions.extr_to) then
- MakeDirectory(ExtractOptions.extr_to);
- ExtractOptions.extr_to := AppendSlash(ExtractOptions.extr_to);
- processfrom := 0;
- processto := Total_Archive-1;
- process(_Extract);
- end;
-
- procedure TCakDir.New_Archive(filename : string);
- begin
- Set_Archive_List(filename);
- Total_Contents := 0;
- processfrom := 0;
- processto := 0;
- end;
-
- procedure TCakDir.Add;
- begin
- if Total_Archive = 0 then exit;
- if (processfrom = -1) and (processto = -1) then
- begin
- processfrom := 0;
- processto := total_archive -1;
- end;
- process(_Add);
- end;
-
- procedure TCakDir.SFX;
- begin
- if Total_Archive = 0 then exit;
- processfrom := sfxoptions.sfx_to;
- processto := processfrom;
- if Archive_List[processfrom]._ARCtype <> _ZIP then
- begin
- Archive_Convert(Archive_List[processfrom]._Arcname,_ZIP);
- Archive_List[processfrom]._Arcname := Removefileext(Archive_List[processfrom]._Arcname) + '.zip';
- Archive_List[processfrom]._Arctype := _ZIP;
- end else
- Copyfile(PCHAR(Archive_List[processfrom]._Arcname),PCHAR(Archive_List[processfrom]._Arcname + '^'),TRUE);
- process(_SFX);
- if fileexists(Archive_List[processfrom]._Arcname + '^') and not fileexists(Archive_List[processfrom]._Arcname) then
- Renamefile(Archive_List[processfrom]._Arcname + '^', Archive_List[processfrom]._Arcname);
- end;
-
- procedure TCakDir.Delete_Archive(arcfrom, arcto : integer);
- begin
- if Total_Archive = 0 then exit;
- processfrom := arcfrom;
- processto := arcto;
- Process(_Delete);
- end;
-
- procedure TCakDir.Delete;
- var i,all : integer;
- begin
- if Total_Archive = 0 then exit;
- all := 0;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- if all = 0 then
- Case MessageDlg(Format('Are you sure want to delete %s?',[Archive_Contents[i]._Filename]), mtWarning, [mbYes, mbNo, mbCancel, mbYesToAll], 0) of
- MrNo : Archive_Contents[i]._Selected := false;
- MrYestoAll : all := 1;
- MrCancel : Clear_Selected_List;
- end;
- if Get_Selected_Count = 0 then exit;
- processfrom := 0;
- processto := Total_Archive-1;
- process(_Delete);
- end;
-
- procedure TCakDir.Test_Archive(arcfrom, arcto : integer);
- begin
- if Total_Archive = 0 then exit;
- processfrom := arcfrom;
- processto := arcto;
- Process(_Test);
- end;
-
- procedure TCakDir.Test;
- begin
- if Total_Archive = 0 then exit;
- processfrom := 0;
- processto := Total_Archive-1;
- process(_Test);
- end;
- function TCakDir.Checkout(arc : integer;openit : boolean) : string;
- var i : integer;
- k : string;
- begin
- i := Gettickcount;
- While Directoryexists(Grabtemppath + inttostr(i)) do
- inc(i);
- k := Grabtemppath + inttostr(i) + '\';
- Extractoptions.extr_to := k;
- Extractoptions.extr_DirNames := true;
- Extractoptions.extr_OverWrite := true;
- Add_All_Selected_List;
- if arc = -1 then
- Extract_Archive(0, Total_Archive-1) else
- Extract_Archive(arc,arc);
- if openit then
- Explorefolder(k);
- result := k;
- end;
- procedure TCakDir.Install(filename : string; arc : integer);
- var k : string;
- astring : Tstrings;
- begin
- k := Checkout(arc,false);
- {$IFDEF USE_SHCN}
- Run(k + filename,'');
- MonitorStart;
- Showmessage('Press <OK> when completed install');
- {$ELSE}
- Runandwait(k + filename,'');
- {$ENDIF}
- {$IFDEF USE_SHCN}
- History.Add('End Logging');
- astring := TStringlist.create;
- astring.AddStrings(MonitorShowChanges);
- astring.SaveToFile(k + 'log.txt');
- astring.free;
- Run(k + 'log.txt','');
- MonitorStop;
- {$ENDIF}
-
- end;
- procedure TCakDir.HotEdit(filename : string; arc : integer);
- var i : integer;
- k,fn : string;
- begin
- if Extractfilepath(filename) <> '' then
- begin
- if Assigned( FOnMsg ) then
- FOnMsg( nil, 0, 'File with path, cannot HotEdit' );
- exit;
- end;
- fn := filename;
- k := GrabTemppath + 'Checkout\';
- With ExtractOptions do
- begin
- extr_OverWrite := true;
- extr_DirNames := False;
- extr_to := k;
- end;
-
- Clear_Selected_List;
- Add_Selected_List(filename, Archive_list[arc]._ARCname);
- overwriteall := 1;
- if Get_Selected_Count = 0 then
- begin
- if Assigned( FOnMsg ) then
- FOnMsg( nil, 0, 'Internal error - File not exists!');
- exit;
- end;
- Extract;
-
- explorefolder(k);
-
- i := MessageDlg('Hot Edit'
- +#13+#10+'--------------------------------------'
- +#13+#10+'File is now located at :'
- +#13+#10+ k
- +#13+#10+'--------------------------------------'
- +#13+#10+'When you finished editing, press <OK>.'
- +#13+#10+'Archive will then be updated.'
- +#13+#10+'If you don`t want to save changes, press <Cancel>.',
- mtWarning, [mbOK, mbCancel], 0);
-
- if i = Mrok then
- begin
- if fileexists(k + fn) then
- begin
- //Clear_Selected_List;
- //Add_Selected_List(filename, Archive_list[arc]._ARCname);
- //Delete;
- With AddOptions do
- begin
- add_to := arc;
- add_useencrypt := false;
- add_usepath := false;
- addmode := [];
- add_files.Clear;
- add_files.Add(k + fn);
- end;
- Add;
- end;
- end else
- Showmessage(k + fn + ' is deleted, update ABORT');
- Deletefile(k + fn);
- RemoveDir(k);
- end;
-
- function TCakDir.Cando(atype : supporttype; awork : worktype) : boolean;
- var b : boolean;
- begin
- b := true;
- LOAD_EXT_DLL;
- Case awork of
- _LoadContents,_Extract :
- begin
- b := (pos(GetArcString(AType),ArcOpenSupport) <> 0);
- end;
- _ADD :
- b := (pos(GetArcString(AType),ArcAddSupport) <> 0);
- end;
-
- result := FunCCheck[Atype, awork] and b;
-
- if not result then
- Case awork of
- _LoadContents : result := Cakext.Supportactions(GetArcString(AType),Ex_LoadContents);
- _Extract : result := Cakext.Supportactions(GetArcString(AType),Ex_Extract);
- _Add : result := Cakext.Supportactions(GetArcString(AType),Ex_Add);
- _SFX : result := Cakext.Supportactions(GetArcString(AType),Ex_SFX);
- _Test : result := Cakext.Supportactions(GetArcString(AType),Ex_TEST);
- _Delete : result := Cakext.Supportactions(GetArcString(AType),Ex_DELETE);
- end;
- end;
-
- procedure TCakDir.Filelist(fltype : filelisttype;filename : string; arcfrom, arcto : integer);
- const totalcolumns = 8;
- columns : array[1..totalcolumns] of string =
- ('Name', 'Type', 'Size','Date','Pack',
- '%','Crc','Path');
- startat : array[1..totalcolumns] of integer =
- (70,140,240,270,360,390,410,460);
- var
- df : Textfile;
- l,i,j,y : integer;
- k : string;
- {$IFDEF USE_PDF}
- aPDFMaker : TPDFMaker;
- {$ENDIF}
- {$IFDEF USE_PDF}
- procedure DrawColumns(aPDFMaker : TPDFMaker);
- var j : integer;
- begin
- With aPDFMaker do
- begin
- for j := 1 to totalcolumns do
- begin
- Canvas.TextOut(startat[j]+5,730,columns[j]);
- Canvas.LineTo(startat[j],50,startat[j],740);
- end;
- canvas.LineTo(startat[1],725,530,725);
- Canvas.DrawRect(startat[1],740,530,50,true);
- Canvas.FontSize := 7;
- y := 710;
- end;
- end;
- procedure DrawColumns2(aPDFMaker : TPDFMaker);
- begin
- With aPDFMaker do
- begin
- Canvas.TextOut(startat[1]+5,730,'File name');
- Canvas.TextOut(startat[4]+5,730,'File date');
- Canvas.TextOut(startat[6],730,'File size (%)');
- Canvas.TextOut(startat[8]+5,730,'File size(k)');
- y := 710;
- end;
- end;
- procedure WriteHeader(aPDFMaker : TPDFMaker);
- begin
- With aPDFMaker do
- begin
- Canvas.FontSize := 15;
- Canvas.font := fiarialBold;
- Canvas.TextOut(50,790,PRODUCT + ' Archive File List');
- Canvas.LineTo(50,810,450,810);
- Canvas.LineTo(50,780,450,780);
- Canvas.Font := fiCentury;
- Canvas.FontSize := 8;
- Canvas.TextOut(150,770,'Archive : '+ Extractfilename(Archive_List[0]._Arcname));
- Canvas.Textout(150,750,'Size : '+ inttostr(Get_Total_Size) + ' (' + SizeinK(Get_Total_Size) + ')');
- Canvas.TextOut(350,770,'Total Files : ' + InttoStr(Total_Contents));
- Canvas.TextOut(350,750,'Page : ' + InttoStr(l));
- end;
- end;
- {$ENDIF}
- begin
- Case fltype of
- _TXT : begin
- assignfile(df,filename);
- rewrite(df);
- for j := arcfrom to arcto do
- begin
- List_Archive(j,j);
- for i := 0 to Total_Contents -1 do
- with Archive_Contents[i] do
- begin
- k := _Filename + ' ';
- k := k + _Filetype + ' ';
- k := k + Inttostr(_Filesize) + ' ';
- k := k + Datetimetostr(_Filetime) + ' ';
- k := k + Inttostr(_FilePackedSize) + ' ';
- k := k + Inttostr(_Fileratio) + ' ';
- k := k + _FileCRC + ' ';
- k := k + _Filedefpath + ' ';
- writeln(df, k);
- end;
- end;
- closefile(df);
- end;
- {$IFDEF USE_PDF}
- _PDF2: begin
- aPDFMaker := TPDFMaker.Create;
- with aPDFMaker do
- begin
- l := 1;
- y := 710;
- BeginDoc(TFileStream.Create(filename, fmCreate));
- WriteHeader(aPDFMaker);
- DrawColumns2(aPDFMaker);
- for i := 0 to Total_Contents -1 do
- with Archive_Contents[i] do
- begin
- Canvas.TextOut(startat[1]+5,y,_filedefpath + _filename);
- Canvas.TextOut(startat[4]+5,y,Datetimetostr(_Filetime));
-
- Canvas.FillColor := clBlack;
- j := trunc(_Filesize / Get_total_size * (startat[8] - startat[6]));
-
- Canvas.DrawandfillRect(startat[6],y,startat[8],y+12,False);
-
- canvas.pStroke;
- Canvas.FillColor := clLime;
- Canvas.FillRect(startat[6]+j,y,startat[8],y+12,False);
- Canvas.DrawRect(startat[6],y,startat[8],y+12,False);
-
- Canvas.FillColor := clBlack;
- j := trunc(_Filesize / Get_total_size * (100));
- Canvas.textout(startat[6] + ((startat[8] - startat[6]) div 2),y + 2, inttostr(j) + '%');
-
- Canvas.TextOut(startat[8]+5,y,SizeinK(_Filesize));
- y := y - 15;
- if y <= 60 then
- if i <> Total_Contents -1 then
- begin
- NewPage;
- y := 710;
- inc(l);
- WriteHeader(aPDFMaker);
- DrawColumns2(aPDFMaker);
- end;
- end;
- EndDoc(true);
- Free;
- end;
- end;
- _PDF : begin
- aPDFMaker := TPDFMaker.Create;
- with aPDFMaker do
- begin
- l := 1;
- BeginDoc(TFileStream.Create(filename, fmCreate));
- WriteHeader(aPDFMaker);
- DrawColumns(aPDFMaker);
- for i := 0 to Total_Contents -1 do
- with Archive_Contents[i] do
- begin
- Canvas.TextOut(startat[1]+5,y,_filename);
- Canvas.TextOut(startat[2]+5,y,_filetype);
- Canvas.TextOut(startat[3]+5,y,Inttostr(_Filesize));
- Canvas.TextOut(startat[4]+5,y,Datetimetostr(_Filetime));
- Canvas.TextOut(startat[5]+5,y,Inttostr(_FilePackedsize));
- Canvas.TextOut(startat[6]+5,y,Inttostr(_Fileratio));
- Canvas.TextOut(startat[7]+5,y,_filecrc);
- Canvas.TextOut(startat[8]+5,y,_filedefpath);
- y := y - 15;
- if y <= 60 then
- if i <> Total_Contents -1 then
- begin
- NewPage;
- y := 710;
- inc(l);
- WriteHeader(aPDFMaker);
- DrawColumns(aPDFMaker);
- end;
- end;
- EndDoc(true);
- Free;
- end;
- end;
- {$ENDIF}
- _HTM : begin
- assignfile(df,filename);
- rewrite(df);
- writeln(df,'<html>' + #10 + '<head> ');
- writeln(df,'<meta name=GENERATOR content=Common Archiver Kit ' + CAKVER + '>');
- writeln(df,'<title> Archive Contents </title>');
- writeln(df,'<body bgcolor=#CFE9C7>');
- for j := arcfrom to arcto do
- begin
- List_Archive(j,j);
- write(df,'<H5>Content of archive: <a href=');
- write(df, Archive_List[j]._Arcname+ '>');
- write(df, Archive_List[j]._Arcname+ '</a> ');
- writeln(df, 'total ' + inttostr(Total_Contents) + ' files.');
- writeln(df,'<HR SIZE=3>');
-
- writeln(df,'<TABLE BORDER=0 cellpadding=1 cellspacing=1>');
- write(df,'<TD>' + columns[1] + '</TD>');
- for l := 2 to totalcolumns do
- write(df,'<TD>' + columns[l] + '<TD>');
-
- for i := 0 to Total_Contents -1 do
- with Archive_Contents[i] do
- begin
- write(df,'<TR><TD>' + _Filename + '</TD>');
- write(df,'<TD>' + _Filetype + '<TD>');
- write(df,'<TD>' + SizeinK(_Filesize) + '<TD>');
- write(df,'<TD>' + Datetimetostr(_Filetime) + '<TD>');
- write(df,'<TD>' + SizeinK(_FilePackedSize) + '<TD>');
- write(df,'<TD>' + Inttostr(_Fileratio) + '%<TD>');
- write(df,'<TD>' + _FileCRC + '<TD>');
- write(df,'<TD>' + _Filedefpath + '<TD>');
- //write(df,'<TD>' + _FileArchive + '<TD>');
- writeln(df);
- end;
- writeln(df,'</TABLE>');
- writeln(df,'<HR SIZE=3>');
- end;
- writeln(df,'</HTML>');
- closefile(df);
- end;
-
-
- end;
- Showmessage('Created ' + filename);
- end;
-
- function TCakDir.translatetype(aworktype : worktype) : worktypeex;
- begin
- Case aworktype of
- _LoadContents : Result := Ex_LoadContents;
- _Extract : Result := Ex_Extract;
- _Add : Result := Ex_Add;
- _SFX : Result := Ex_SFX;
- _TEST : Result := Ex_Test;
- _Delete : Result := Ex_Delete;
- else Result := EX_None;
- end;
- end;
-
- function TCakDir.Process(processwhat : worktype) : boolean;
- var k : string;
- tickcount : Word;
- i : integer;
- CakDir1 : TCakDir;
- arctype : supporttype;
- begin
- if MRUList.IndexOf(Archive_List[0]._Arcname) <> -1 then
- MRUList.Delete(MRUList.IndexOf(Archive_List[0]._Arcname));
-
- MRUList.Insert(0,Archive_List[0]._Arcname);
-
- if MAXMRU > 0 then
- while MRUList.Count > MAXMRU do
- MRUList.Delete(MRUList.count -1);
-
- stopping := false;
- result := false;
- if (processfrom = -1) or (processto = -1) then exit;
- Case processwhat of
- _Extract : k := 'Extracting archive';
- _Test : k := 'Testing archive';
- _Add : k := 'Adding files to archive';
- _Delete : k := 'Deleting files from archive';
- _SFX : k := 'Creating SFX';
- else k := '';
- end;
- if (processwhat <> _ADD) then
- if (processfrom = 0) and (processto = 0) then
- if not fileexists(Archive_List[0]._Arcname) then
- if assigned(FOnMsg) then
- FOnMsg(nil,0,Format('Warning, %s not found',[Extractfilename(Archive_List[0]._Arcname)]));
-
- if paramcount > 0 then
- if paramstr(0) = '/CAKVER' then
- Showmessage('CAK' + CAKVER);
-
- if k <> '' then
- if Assigned( FOnMsg ) then
- FOnMsg( nil, 0, k );
-
- tickcount := gettickcount;
-
- LOAD_EXT_DLL;
- if Cakext.Supportactions(Extractfileext(Archive_List[processfrom]._Arcname),translatetype(processwhat)) then
- begin
- ProcessExt(processwhat);
- end else
- Case Archive_List[processfrom]._ARCtype of
- {$IFDEF USE_ZIP} _ZIP : result := ProcessZIP(processwhat);
- {$ELSE}
- {$IFDEF USE_ARC}
- _ZIP : result := ProcessARC(processwhat);
- {$ENDIF}
- {$ENDIF}
- {$IFDEF USE_ARC} _LHA : result := ProcessARC(processwhat); {$ENDIF}
- {$IFDEF USE_ARC} _RAR : result := ProcessARC(processwhat); {$ENDIF}
- _CAB : result := ProcessCAB(processwhat);
- _PAK : result := ProcessPAK(processwhat);
- {$IFDEF USE_ARC} _ARJ : result := ProcessARC(processwhat); {$ENDIF}
- {$IFDEF USE_ARC} _TAR : result := ProcessARC(processwhat); {$ENDIF}
- {$IFDEF USE_ARC} _TGZ : result := ProcessARC(processwhat); {$ENDIF}
- {$IFDEF USE_ACE} _ACE : result := ProcessACE(processwhat); {$ENDIF}
- {$IFDEF USE_ARC} _BZ2 : result := ProcessARC(processwhat); {$ENDIF}
- {$IFDEF USE_ARC} _BEL : result := ProcessARC(processwhat); {$ENDIF}
- {$IFDEF USE_ARC} _GCA : result := ProcessARC(processwhat); {$ENDIF}
- {$IFDEF USE_ARC} _YZ1 : result := ProcessARC(processwhat); {$ENDIF}
- {$IFDEF USE_ARC} _BZA : result := ProcessARC(processwhat); {$ENDIF}
- {$IFDEF USE_RS} _RS : result := ProcessRS(processwhat); {$ENDIF}
- {$IFDEF USE_CZIP}_CZIP: result := ProcessCZIP(processwhat);{$ENDIF}
- {$IFDEF USE_INDY}_B64 : result := ProcessB64(processwhat); {$ENDIF}
- {$IFDEF USE_INDY}_UUE : result := ProcessUUE(processwhat); {$ENDIF}
- {$IFDEF USE_INDY}_XXE : result := ProcessXXE(processwhat); {$ENDIF}
- _AKS : ProcessAKS(processwhat);
- _WIT : result := false;
- else result := false;
- end;
- if processwhat = _LoadContents then
- begin
- for i := 0 to total_Archive -1 do
- Archive_List[i]._ARCsize := CalcFolderSize(Archive_List[i]._Arcname);
- Full_Contents := Archive_Contents;
- FullContentcount := Total_Contents;
- end;
-
- if processwhat = _Extract then
- if extractOptions.extr_ArcINArc then
- begin
- CakDir1 := TCakDir.Create(nil);
- for i := 0 to Total_Contents -1 do
- begin
- k := Appendslash(Extractoptions.extr_to) + Archive_Contents[i]._Filename;
- arctype := getarctype(k);
- if arctype <> _WIT then
- if cando(arctype,_Extract) then
- begin
- CakDir1.Set_Archive_List(k);
- CakDir1.List_Archive(0,0);
- CakDir1.Add_All_Selected_List;
- CakDir1.Extractoptions := Extractoptions;
- CakDir1.OnCMessage := OnCMessage;
- CakDir1.OnCProgress := OnCProgress;
- CakDir1.OnCOverwrite := OnCOverwrite;
- CakDir1.Extract;
- end;
- end;
- CakDir1.Free;
- end;
- Clear_Selected_List;
- Clear_Add_List;
- overwriteall := 0;
-
- if k <> '' then
- begin
- //k := 'Time used : ' + inttostr((gettickcount - tickcount)div 10000) + 'ms';
- //if Assigned( FOnMsg ) then
- // FOnMsg( nil, 0, k );
- end;
-
-
- if Assigned( FOnProg ) then
- FOnProg(nil,'', TotalProgress,TotalProgress);
- end;
- procedure TCakDir.reiniticons;
- var shinfo : TSHFileInfo;
- Icon : TIcon;
- i : integer;
- begin
- ImageS.Clear;
- ImageL.Clear;
- Filetype.Clear;
- Icon := TIcon.create();
- for i := 0 to fileext.count -1 do
- begin
- SHGetFileInfo(PChar(fileext.strings[i]), 0, shInfo, SizeOf(shInfo),
- (SHGFI_SYSICONINDEX or SHGFI_USEFILEATTRIBUTES)
- or (SHGFI_ICON or SHGFI_TYPENAME));
- icon.Handle := shinfo.hIcon;
- imageS.AddIcon(icon);
- imageL.addicon(icon);
- Filetype.Add(Shinfo.szTypeName);
- end;
- Icon.free;
- end;
- function TCakDir.isLocked(filename : string) : boolean;
- var fs : Tfilestream;
- begin
- result := false;
- try
- fs:= Tfilestream.Create( filename, fmOpenRead or fmShareExclusive );
- fs.Free;
- except
- result := true;
- end;
- end;
- function TCakDir.returnicontype(filename : string) : integer;
- var loc : integer;
- ext : string;
- shinfo : TSHFileInfo;
- Icon : TIcon;
- begin
- Icon := TIcon.create();
- ext := Extractfileext(filename);
- loc := FileExt.IndexOf(ext);
- if (loc = -1) then {Use Cache}
- begin
- SHGetFileInfo(PChar('.' + ext), 0, shInfo, SizeOf(shInfo),
- (SHGFI_SYSICONINDEX or SHGFI_USEFILEATTRIBUTES)
- or (SHGFI_ICON or SHGFI_TYPENAME));
- icon.Handle := shinfo.hIcon;
- loc := imageS.AddIcon(icon);
- imageL.addicon(icon);
- FileExt.Add(ext);
- Filetype.Add(Shinfo.szTypeName);
- end;
- result := loc;
- Icon.free;
- end;
-
-
-
- {$IFDEF USE_RS}
- function TCakDir.ProcessRS(processwhat : worktype) : boolean;
- var
- List: TList;
- i: integer;
- k: string;
- ColMan: TObjList;
- dummystrings : tstrings;
-
- begin
- LOAD_RS_DLL;
- result := false;
- if Rsdir.ArchiveMan.archive_file_full_path <> Archive_List[processfrom]._ArcName then
- begin
- RsDir.ArchiveMan.TempDir := temppath;
- RsDir.ArchiveMan.OpenArchive(Archive_List[processfrom]._ArcName, True);
-
- end;
-
- case Processwhat of
- _LoadContents : begin {DoNothing} end;
- _Add : begin
- dummystrings := TStringlist.create;
- RsDir.ArchiveMan.use_folder_names := AddOptions.add_usepath;
- for i := 0 to Addoptions.add_files.count -1 do
- begin
- dummystrings.clear;
- dummystrings.add(Extractfilename(Addoptions.add_files.strings[i]));
- RsDir.ArchiveMan.Addfiles(dummystrings,extractfilepath(Addoptions.add_files.strings[i]));
- end;
- dummystrings.free;
-
-
- end;
- _Extract : begin
- RsDir.ArchiveMan.dest_dir := ExtractOptions.extr_to;
- RsDir.ArchiveMan.use_folder_names := False; //Extract_sc.Usefolder;
- List := TList.Create;
- ColMan := TObjList.Create;
- ColMan.Add(TNameColDataExtr.Create);
- try
- for i := 0 to Total_Contents - 1 do
- begin
- with RsDir.ArchiveMan.ArchiveFile do
- k := TColDataExtr(ColMan[0]).Extract
- (TCentralFileHeader(CentralDir[i]));
-
- if Archive_contents[Get_Archive_Code(Rsdir.ArchiveMan.archive_file_full_path,k)]._Selected then
- List.Add(RsDir.ArchiveMan.ArchiveFile.CentralDir[i]);
- end;
- RsDir.ArchiveMan.ExtractList(List, Total_Unpacked, totalprogress);
- finally
- List.Free;
- ColMan.Free;
- if Assigned( FOnProg ) then
- FOnProg( nil, '', Total_Unpacked, Trunc((Total_Contents/totalprogress)*100));
-
- end;
- end
- else if Assigned( FOnMsg ) then
- FOnMsg( nil, 0, FUNCNOTAVIL );
- end;
-
- end;
- {$ENDIF}
-
- {$IFDEF USE_CZIP}
- function TCakDir.ProcessCZIP(processwhat : worktype) : boolean;
- var i : integer;
- k : string;
- continue : boolean;
- begin
- result := false;
- if assigned(FOnCryto) then
- FOnCryto(nil,key1,key2,key3);
- Case Processwhat of
- _LoadContents : begin
- For i := processfrom to processto do
- begin
- k := Copy(Archive_List[i]._ARCname, 0, Pos('.', Archive_List[i]._ARCname) - 1);
- Encryptit.DecryptFile(Archive_List[i]._ARCname, k + '.zip', key1, key2, key3);
- continue := true;
- {$IFDEF USE_WINEXT}
- if GetARCtype2(k + '.zip') <> _ZIP then
- begin
- continue := false;
- if Assigned( FOnMsg ) then
- FOnMSG(nil,0,'Wrong key or damaged archives');
- end;
- {$ENDIF}
- if continue then
- Archive_List[i]._ARCname := k + '.zip';
- end;
- if GetARCtype(Archive_List[processfrom]._ARCname) = _ZIP then
- ProcessZip(_LoadContents);
- end;
- else ProcessZIP(processwhat);
- end;
- end;
- {$ENDIF}
-
- {$IFDEF USE_ZIP}
- function TCakDir.ProcessZIP(processwhat : worktype) : boolean;
- var i,j,loc,l : integer;
- ext,k : string;
- Icon : TICON;
- timestr,k2,k3 : string;
- afilelist : tstrings;
- function changeslash(input : string) : string;
- var i : integer;
- k : string;
- begin
- k := input;
- for i := 0 to length(k) do
- if (k[i] = '/') or (k[i] = '\') then k[i] := '-';
- result := k;
- end;
- begin
- result := false;
- Load_ZIP_DLL;
- Case Processwhat of
- _SFX : begin
- Zipdir.zipfilename := Archive_List[sfxoptions.sfx_to]._arcname;
- Zipdir.sfxMessage := sfxoptions.sfx_message;
- Zipdir.sfxCaption := sfxoptions.sfx_caption;
- Zipdir.sfxcommandline := sfxoptions.sfx_commandline;
- Zipdir.SFXOptions := [];
- if SFXOptions.sfx_autorun then
- Zipdir.SFXOptions := Zipdir.SFXOptions + [SFXAutoRun];
-
- Zipdir.SFXOverWriteMode := OvrConfirm;
- if SFXOptions.sfx_overwrite then
- Zipdir.SFXOverWriteMode := OvrAlways;
-
- Zipdir.SFXPath := sfxoptions.sfx_extractto;
- zipdir.ConvertSFX;
- end;
- _Test : begin
- //Zipdir.TempDir := ExtractOptions.extr_to;
- Zipdir.ExtrOptions := [ExtrTest];
- For j := processfrom to processto do
- begin
- Zipdir.ZipFileName := Archive_List[j]._ARCname;
- Zipdir.Extract;
- end;
- end;
- _Extract : begin
- if length(ExtractOptions.extr_to) > 3 then
- Zipdir.ExtrBaseDir := removeslash(ExtractOptions.extr_to) + '\' else
- Zipdir.ExtrBaseDir := Removeslash(ExtractOptions.extr_to);
- SetcurrentDir(removeslash(ExtractOptions.extr_to));
- For j := processfrom to processto do
- if Get_Selected_Count(Archive_List[j]._ARCname) > 0 then
- begin
- Zipdir.ZipFileName := Archive_List[j]._ARCname;
- Zipdir.FSpecArgs.Clear;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- if Archive_Contents[i]._FileArchive = Archive_List[j]._ARCname then
- begin
- k := appendslash(ExtractOptions.extr_to) + Archive_Contents[i]._Filedefpath;
- if not directoryexists(k) then
- MakeDirectory(k);
- Zipdir.FSpecArgs.Add(Archive_Contents[i]._Filedefpath + Archive_Contents[i]._Filename);
- end;
-
- Zipdir.ExtrOptions := [];
- if ExtractOptions.extr_Dirnames then
- Zipdir.ExtrOptions := Zipdir.ExtrOptions + [ExtrDirNames];
- if ExtractOptions.extr_overwrite then
- Zipdir.ExtrOptions := Zipdir.ExtrOptions + [ExtrOverwrite];
- overwriteall := 0;
- Zipdir.Extract;
- end;
- end;
- _Add : begin
- Zipdir.ZipFileName := Archive_List[AddOptions.add_to]._ARCname;
-
- afilelist := Tstringlist.create();
- Zipdir.AddOptions := [];
- if Addoptions.add_dosformat then
- Zipdir.Addoptions := Zipdir.Addoptions + [AddForceDos];
- if Addoptions.add_hidden then
- Zipdir.Addoptions := Zipdir.Addoptions + [AddHiddenFiles];
- if _refresh in Addoptions.add_mode then
- Zipdir.AddOptions := Zipdir.Addoptions + [AddFreshen] else
- if _update in Addoptions.add_mode then
- Zipdir.AddOptions := Zipdir.Addoptions + [AddUpdate] else
- if _move in Addoptions.add_mode then
- Zipdir.AddOptions := Zipdir.Addoptions + [AddMove];
- if Addoptions.add_usepath then
- Zipdir.AddOptions := Zipdir.Addoptions + [AddDirnames];
- if Addoptions.add_useencrypt then
- if Addoptions.add_encrypt <> '' then
- begin
- Zipdir.AddOptions := Zipdir.Addoptions + [AddEncrypt];
- Zipdir.Password := Addoptions.add_encrypt;
- end;
- afilelist.Clear;
-
- for i := 0 to AddOptions.Add_files.Count -1 do
- afilelist.AddStrings(pollfilelist(Addoptions.add_files.strings[i],Addoptions.add_SubDir));
-
- if not versioncontrol then
- if AddOptions.add_relative then
- Zipdir.RootDir := Removeslash(Extractfilepath(Archive_List[AddOptions.add_to]._ARCname)) else
- Zipdir.RootDir := '';
-
- if not versioncontrol then
- if AddOptions.add_relative then
- for i := 0 to Afilelist.count -1 do
- if Copy(uppercase(Afilelist.strings[i]),0,length(zipdir.rootdir)) = uppercase(zipdir.rootdir) then
- afilelist.strings[i] := '\' + Copy(afilelist.strings[i],length(zipdir.rootdir) + 1, length(afilelist.strings[i]) - length(zipdir.rootdir));
-
- if not versioncontrol then
- begin
- For i := 0 to AddOptions.add_exclude.Count -1 do
- begin
- j := AddOptions.Add_files.Indexof(AddOptions.add_exclude.Strings[i]);
- if j <> -1 then AddOptions.Add_files.Delete(j);
- end;
- Zipdir.RootDir := AddOptions.add_basedir;
- Zipdir.FSpecArgs.Clear;
- Zipdir.FSpecArgs.AddStrings(afilelist);
- try
- Zipdir.Add;
- finally
- AddOptions.add_files.Clear;
- end;
- end else
- begin {VERSIONCONTROL}
-
- timestr := changeslash(Datetimetostr(now));
-
- //for i := 0 to AddOptions.Add_files.Count -1 do
- // afilelist.AddStrings(pollfilelist(Addoptions.add_files.strings[i],Addoptions.add_SubDir));
-
- afilelist.AddStrings(addoptions.add_files);
-
- for i := 0 to afilelist.count -1 do
- begin
- Load_ZIP_Dll;
- Zipdir.ZipFileName := Archive_List[AddOptions.add_to]._ARCname;
- k := afilelist.strings[i];
- k2 := Appendslash(extractfilepath(k)) + '+' + Extractfilename(k);
- k3 := k2;
-
- copyfile(pchar(k),pchar(k2),true);
- if AddOptions.add_usepath then
- Zipdir.AddOptions := Zipdir.Addoptions + [AddDirnames] else
- Zipdir.AddOptions := Zipdir.Addoptions - [AddDirnames];
- Zipdir.FSpecArgs.Add(k2);
- Zipdir.Add;
- if AddOptions.add_usepath then
- begin
- k2 := removedrive(k2);
- k := removedrive(k);
- end else
- begin
- k2 := extractfilename(removedrive(k2));
- k := extractfilename(removedrive(k));
- end;
- Zipdirrename(k2,timestr + '\' + k);
- sysutils.DeleteFile(k3);
- UnLoad_ZIP_Dll;
- end;
-
- end;
-
- AddOptions.add_files.Clear;
- Zipdir.RootDir := '';
- afilelist.free;
- end;
- _Delete : begin
- For j := processfrom to processto do
- begin
- Zipdir.ZipFileName := Archive_List[j]._ARCname;
- Zipdir.FSpecArgs.Clear;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- if Archive_Contents[i]._FileArchive = Archive_List[j]._ARCname then
- Zipdir.FSpecArgs.Add(Archive_Contents[i]._Filedefpath + Archive_Contents[i]._Filename);
- Zipdir.Delete;
- end;
-
- end;
- _CryptoZip : begin
- if assigned(FOnCryto) then
- FOnCryto(nil,key1,key2,key3);
- k := Removefileext(Archive_List[processfrom]._ARCname);
- Encryptit.EncryptFile(Archive_List[processfrom]._ARCname,k + '.czip', key1, key2, key3);
- end;
-
- _LoadContents : begin
- icon := TICON.Create;
- DirectoryList.clear;
- l := -1;
- try
- Total_Contents := 0;
- for j := processfrom to processto do
- begin
- zipdir.ZipFileName := Archive_List[j]._ARCname;
- if zipdir.ZipFileName = '' then Archive_List[j]._ARCtype := _WIT;
- Archive_List[j]._ARCneedpassword := false;
- SetLength(Archive_Contents, Total_Contents + zipdir.Count);
- for i := 0 to zipdir.Count -1 do
- with ZipDirEntry( ZipDir.ZipContents[i]^ ) do
- begin
- l := l + 1;
- {Filename} Archive_Contents[l]._Filename := Extractfilename(Filename);
- ext := Extractfileext(filename);
- loc := returnicontype(filename);
- Archive_Contents[l]._Fileicon := loc;
- Archive_Contents[l]._FileType := Filetype.strings[loc];
- {FileRatio} if UnCompressedSize <> 0 then
- Archive_Contents[l]._FileRatio := trunc((1-(CompressedSize / UnCompressedSize) ) * 100) else
- Archive_Contents[l]._FileRatio := 0;
- {Encrypted?} Archive_Contents[l]._encrypted := Encrypted;
- if encrypted then
- Archive_List[j]._ARCneedpassword := true;
- Archive_Contents[l]._FileSize := UnCompressedSize;
- Archive_Contents[l]._FilePackedSize := CompressedSize;
- Archive_Contents[l]._FileTime := FileDateToDateTime( DateTime );
- Archive_Contents[l]._FileCRC := InttoHex(CRC32,8);
- Archive_Contents[l]._FileDefPath := Extractfilepath(Filename);
- if DirectoryList.IndexOf(Archive_Contents[l]._FileDefPath) = -1 then
- if (Archive_Contents[i]._FileDefPath) <> '' then
- DirectoryList.Add(Archive_Contents[l]._FileDefPath);
- Archive_Contents[l]._FileArchive := Archive_List[j]._ARCname;
- end;
- Total_Contents := Total_Contents + zipdir.Count
- end;
- finally
- Icon.Free;
- if Total_Contents > 0 then
- Total_Contents := l + 1;
- SetLength(Archive_Contents, Total_Contents);
- end;
- end;
-
- else if Assigned( FOnMsg ) then
- FOnMsg( nil, 0, FUNCNOTAVIL );
- end;
- end;
- {$ENDIF}
-
- {$IFDEF USE_ACE}
- procedure TCakdir.AceDirExtracting(Sender: TObject; eFile: TACEHeaderData);
- begin
- inc(processed_files);
- if Assigned( FOnProg ) then
- FOnProg( nil, efile.FileName, efile.UnpSize, Trunc((Total_Contents/processed_files)*100));
- end;
- {$ENDIF}
-
- {$IFDEF USE_ACE}
- procedure TCakdir.AceDirError(Sender: TObject; Error: Integer);
- begin
- if Assigned( FOnMsg ) then
- Case Error of
- 11 : FOnMsg( nil, Error, ACEINTERR );
- 128 : FOnMsg( nil, Error, NOERR );
- 132 : FOnMsg( nil, Error, METHODNOTSUPPORT );
- else
- FOnMsg( nil, Error, '' );
- end;
- end;
- {$ENDIF}
- {$IFDEF USE_ACE}
- procedure TCakDir.AceDirList(Sender: TObject; eFile: TACEHeaderData;
- Result: Boolean);
- var loc : integer;
- ext : string;
- Icon : TICON;
- begin
- DirectoryList.clear;
- icon := TICON.Create;
- Inc(Total_Contents);
- try
- SetLength(Archive_Contents, Total_Contents + 1);
- with efile do
- begin
- Archive_Contents[Total_Contents]._Filename := Extractfilename(Filename);
- ext := Extractfileext(filename);
- loc := returnicontype(filename);
- Archive_Contents[Total_Contents]._Fileicon := loc;
- Archive_Contents[Total_Contents]._FileType := Filetype.strings[loc];
- if UnpSize <> 0 then
- Archive_Contents[Total_Contents]._FileRatio := trunc((1-(PackSize / UnpSize) ) * 100) else
- Archive_Contents[Total_Contents]._FileRatio := 0;
- Archive_Contents[Total_Contents]._encrypted := FALSE;
- Archive_Contents[Total_Contents]._FileSize := UnpSize;
- Archive_Contents[Total_Contents]._FilePackedSize := PackSize;
- Archive_Contents[Total_Contents]._FileTime := FileDateToDateTime( FileTime );
- Archive_Contents[Total_Contents]._FileCRC := InttoHex(FileCRC,8);
- Archive_Contents[Total_Contents]._FileDefPath := Extractfilepath(Filename);
- if DirectoryList.IndexOf(Archive_Contents[Total_Contents]._FileDefPath) = -1 then
- if (Archive_Contents[Total_Contents]._FileDefPath) <> '' then
- DirectoryList.Add(Archive_Contents[Total_Contents]._FileDefPath);
- Archive_Contents[Total_Contents]._FileArchive := Archive_List[processing]._ARCname;
- end;
- finally
- Icon.Free;
- end;
-
- end;
- {$ENDIF}
-
- {$IFDEF USE_ARC}
- procedure TCakDir.ArcDirProgress( Sender:TObject;State:Integer;lpEis:LPEXTRACTINGINFOEX;var Abort: Boolean );
- begin
- Application.ProcessMessages;
- Abort := Stopping;
- if lpEis = nil then exit;
- with lpEis^,lpEis^.exinfo do
- if Lastname <> szSourceFileName then
- //if Archive_Contents[Get_Archive_Code(szSourceFileName,ArcDir.filename)]._Selected then
- begin
- Lastname := szSourceFilename;
- Inc(TotalSize,dwFileSize);
- if Assigned( FOnProg ) then
- FOnProg( nil, ExtractFileName( szSourceFileName ), dwWriteSize, TotalSize);
- end;
- end;
- {$ENDIF}
-
- {$IFDEF USE_ARC}
- procedure TCakDir.ARCHandleError(code : integer);
- begin
- if Assigned( FOnMsg ) then
- Case code of
- 0,1 : FOnMsg(nil,0,NOERR);
- ERROR_DISK_SPACE : FOnMsg(nil,ERROR_DISK_SPACE,ERR_NODISKSPACE);
- ERROR_READ_ONLY : FOnMsg(nil,ERROR_READ_ONLY,ERR_READONLY);
- ERROR_USER_SKIP, ERROR_USER_CANCEL : FOnMsg(nil,ERROR_USER_SKIP,ERR_USERSKIP);
- ERROR_FILE_CRC : FOnMsg(nil, ERROR_FILE_CRC,ERR_CRC);
- ERROR_UNKNOWN_TYPE : FOnMsg(nil,ERROR_UNKNOWN_TYPE,ERR_UNKTYPE);
- ERROR_METHOD : FOnMsg(nil,ERROR_METHOD ,ERR_NOSUPPORT);
- ERROR_PASSWORD_FILE : FOnMsg(nil,ERROR_PASSWORD_FILE ,ERR_PASSWORD);
- ERROR_LONG_FILE_NAME : FOnMsg(nil,ERROR_LONG_FILE_NAME ,ERR_LONGFN);
- ERROR_VERSION : FOnMsg(nil,ERROR_VERSION , ERR_WRONGVER);
- ERROR_FILE_OPEN : FOnMsg(nil,ERROR_FILE_OPEN,ERR_OPENED);
- ERROR_MORE_FRESH : FOnMsg(nil,ERROR_MORE_FRESH,ERR_NEWER);
- ERROR_NOT_EXIST : FOnMsg(nil,ERROR_NOT_EXIST,ERR_NOTEXIST);
- ERROR_ALREADY_EXIST : FOnMsg(nil,ERROR_ALREADY_EXIST,ERR_EXIST);
- ERROR_TOO_MANY_FILES : FOnMsg(nil,ERROR_TOO_MANY_FILES, ERR_TOOMANYFILE);
- ERROR_MAKEDIRECTORY : FOnMsg(nil,ERROR_MAKEDIRECTORY,ERR_MAKEDIR);
- ERROR_CANNOT_WRITE : FOnMsg(nil,ERROR_CANNOT_WRITE, ERR_WRITE);
- ERROR_HUFFMAN_CODE : FOnMsg(nil,ERROR_HUFFMAN_CODE, ERR_HUFFAN);
- ERROR_COMMENT_HEADER : FOnMsg(nil,ERROR_COMMENT_HEADER,ERR_HEADER);
- ERROR_HEADER_CRC : FOnMsg(nil,ERROR_HEADER_CRC,ERR_CRCHEADER);
- ERROR_HEADER_BROKEN : FOnMsg(nil,ERROR_HEADER_BROKEN,ERR_HEADERBROKE);
- ERROR_ARC_FILE_OPEN : FOnMsg(nil,ERROR_ARC_FILE_OPEN,ERR_OPENED);
- ERROR_NOT_ARC_FILE : FOnMsg(nil,ERROR_NOT_ARC_FILE,ERR_NOTARC);
- ERROR_CANNOT_READ : FOnMsg(nil,ERROR_CANNOT_READ,ERR_CANTREAD);
- ERROR_FILE_STYLE : FOnMsg(nil,ERROR_FILE_STYLE,ERR_WRONGTYPE);
- ERROR_COMMAND_NAME : FOnMsg(nil,ERROR_COMMAND_NAME,ERR_WRONGCMD);
- ERROR_MORE_HEAP_MEMORY : FOnMsg(nil,ERROR_MORE_HEAP_MEMORY,ERR_MOREHEAP);
- ERROR_ENOUGH_MEMORY : FOnMsg(nil,ERROR_ENOUGH_MEMORY,ERR_NOMEMORY);
- ERROR_ALREADY_RUNNING : FOnMsg(nil,ERROR_ALREADY_RUNNING,ERR_RUNNING);
- ERROR_HARC_ISNOT_OPENED : FOnMsg(nil,ERROR_HARC_ISNOT_OPENED,ERR_HARC);
- ERROR_NOT_SEARCH_MODE : FOnMsg(nil,ERROR_NOT_SEARCH_MODE,ERR_SEARCH);
- ERROR_NOT_SUPPORT : FOnMsg(nil,ERROR_NOT_SUPPORT,ERR_NOSUPPORT);
- ERROR_TIME_STAMP : FOnMsg(nil,ERROR_TIME_STAMP,'Wrong timestamp');
- ERROR_ARC_READ_ONLY : FOnMsg(nil,ERROR_ARC_READ_ONLY,ERR_ARCREADONLY);
- ERROR_TMP_OPEN : FOnMsg(nil,ERROR_TMP_OPEN,ERR_TMPOPEN);
- ERROR_SAME_NAME_FILE : FOnMsg(nil,ERROR_SAME_NAME_FILE,ERR_SAMENAME);
- ERROR_NOT_FIND_ARC_FILE : FOnMsg(nil,ERROR_NOT_FIND_ARC_FILE,ERR_NOTFOUNDARC);
- ERROR_RESPONSE_READ : FOnMsg(nil,ERROR_RESPONSE_READ,ERR_NORESPONSE);
- ERROR_NOT_FILENAME : FOnMsg(nil,ERROR_NOT_FILENAME,ERR_NOTVALID);
- ERROR_TMP_COPY : FOnMsg(nil,ERROR_TMP_COPY,ERR_COPYTEMP);
- ERROR_EOF : FOnMsg(nil,ERROR_EOF,ERR_EOF);
- end;
- end;
- {$ENDIF}
- procedure TCakDir.CabRCopyFile(Sender: TObject; const FileName: String; UncompressedSize: Integer; Date, Time,
- Attribs: Smallint; var Action: TFileCopyAction;
- var DestFileHandle: Integer);
- var i : integer;
- begin
- Case Cabmode of
- _CFList : begin
- Inc(Total_Contents);
- SetLength(Archive_Contents,Total_Contents);
- with Archive_Contents[Total_Contents-1] do
- begin
- _Filename := Extractfilename(modifyslash(Filename));
- _FileSize := UncompressedSize;
- _FilePackedSize := UncompressedSize;
- _FileICON := returnicontype(_Filename);
- _Filetype := Filetype.strings[_Fileicon];
- _FileRatio := 100;
- _encrypted := False;
- _FileTime := DosDatetimetoDatetime(Word(Date),Word(Time));
- _FileCRC := 'FFFFFF';
- _FileDefPath := Extractfilepath(modifyslash(Filename));
- if DirectoryList.IndexOf(_FileDefPath) = -1 then
- if (_FileDefPath) <> '' then
- DirectoryList.Add(_FileDefPath);
- _FileArchive := Archive_List[processing]._ARCname;
- Action := fcaSkip;
- end;
- end;
- _CFExtract : if stopping then Action := fcaSkip else
- begin
- i := Get_archive_code(Archive_List[processing]._ARCname,modifyslash(filename));
- if (i = -1)
- then Action := fcaSkip else
- if not Archive_Contents[i]._Selected then
- Action := fcaSkip else
- begin
- TotalProgress := TotalProgress + UnCompressedSize;
- if assigned(FOnProg) then
- FOnProg(nil,Filename,UncompressedSize,TotalProgress);
- Action := fcaDefaultCopy;
- end;
- end;
- end;
-
- end;
-
- procedure TcakDir.CabRDirCloseCopied(Sender: TObject;
- const FileName: String; FileHandle: Integer; Date, Time,
- Attribs: Smallint; FolderIndex: Integer; Execute: Boolean;
- var Abort: Boolean);
- begin
- if Assigned(FOnProg) then
- FOnProg(Sender,Filename,0,0);
- if Assigned(FOnMsg) then
- FOnMsg(Sender,0,Filename + ' is Extracted');
- Abort := Stopping;
- end;
- {
- procedure TCakDir.CabWGetOpenInfo(Sender: TObject; const FileName: String; var Date, Time, Attributes: Smallint;
- var FileHandle, ResultCode: Integer);
- begin
- if assigned(FOnProg) then
- FOnProg(nil,Filename,0,0);
- if assigned(FOnMsg) then
- Case ResultCode of
- 0 : FOnMsg(Sender,ResultCode,NOERR);
- 1 : FOnMsg(Sender,ResultCode,ERR_CANTREAD);
- // Failure opening file to be stored in cabinet
- // erf.erfTyp has C run-time *errno* value
- 2 : FOnMsg(Sender,ResultCode,ERR_CANTREAD);
- // Failure reading file to be stored in cabinet
- // erf.erfTyp has C run-time *errno* value
- 3 : FOnMsg(Sender,ResultCode,ERR_NOMEMORY);
- // Out of memory in FCI
- 4 : FOnMsg(Sender,ResultCode,ERR_COPYTEMP);
- // Could not create a temporary file
- // erf.erfTyp has C run-time *errno* value
- 5 : FOnMsg(Sender,ResultCode,ERR_NOSUPPORT );
- // Unknown compression type
- 6 : FOnMsg(Sender,ResultCode,ERR_WRITE );
- // Could not create cabinet file
- // erf.erfTyp has C run-time *errno* value
- 7 : FOnMsg(Sender,ResultCode,ERR_USERSKIP );
- // Client requested abort
- 8 : FOnMsg(Sender,ResultCode,ERR_WRITE );
- // Failure compressing data
- end;
- end; }
- procedure TCakDir.CabWFilePlaced(Sender: TObject; var CabParameters: TCCAB; const FileName: String; FileLength: Integer;
- Continuation: Boolean; var AbortProcessing: Boolean);
- begin
- Inc(TotalProgress,FileLength);
- if assigned(FOnMsg) then
- FOnMsg(Sender,0,Filename);
- if assigned(FOnProg) then
- FOnProg(nil,Filename,FileLength,TotalProgress);
- abortProcessing := Stopping;
- end;
- procedure TCakDir.CabRNextCab(Sender: TObject;
- const NextCabinetName, NextCabinetDisk: String; var CabinetPath: String;
- ErrorIndication: TFDIERROR; var Abort: Boolean);
- var Opendialog : TOpendialog;
- begin
- Opendialog := TOpendialog.Create(nil);
- Opendialog.Title := 'Please locate ' + NextCabinetDisk + ' (' + NextCabinetName + ')';
- Opendialog.Filter := 'Cabinet|*.cab';
- Abort := false;
- if opendialog.execute then
- cabinetpath := Opendialog.filename else
- Abort := true;
- end;
- function TCakDir.ProcessPAK(processwhat : worktype) : boolean;
- var
- // Buf1 : array[1..4] of Char;
- Buf2 : array[1..4] of Byte;
- Buf3 : array[1..56] of Char;
- Buf4 : array[1..120] of Char;
- Buf5 : array[1..16] of Char;
- Buf6 : array[1..120] of Byte;
- sign : longint;
- f,ff : file;
- fsize : longint;
- NumRead, offset, contents : longint;
- i,j,k,loc : integer;
- function HexToInt(HexStr: String): LongInt;
- var
- s : string;
- begin
- s := '$' + HexStr;
- result := StrToInt(s);
- end;
-
- function IntToHex(DecValue: Integer): String;
- begin
- result:= Format('%0x', [DecValue]);
- end;
- function buf5tostr : string;
- var i : integer;
- output : string;
- begin
- output := '';
- i := 1;
- While (Buf5[i] <> #0) and (i < 16) do
- begin
- output := output + Char(Buf5[i]);
- inc(i);
- end;
- result := output;
- end;
-
- function buf4tostr : string;
- var i : integer;
- output : string;
- begin
- output := '';
- i := 1;
- While (Buf4[i] <> #0) and (i < 120) do
- begin
- output := output + Char(Buf4[i]);
- inc(i);
- end;
- result := output;
- end;
- function buf3tostr : string;
- var i : integer;
- output : string;
- begin
- output := '';
- i := 1;
- While (Buf3[i] <> #0) and (i < 53) do
- begin
- output := output + Char(Buf3[i]);
- inc(i);
- end;
- result := output;
- end;
- function buf2toint : integer;
- var x : byte;
- s : string;
- i : integer;
- hexstr : string;
- begin
- hexstr:= '';
- for i := 4 downto 1 do
- begin
- x:= Buf2[i];
- s:= IntToHex(x);
- HexStr:= HexStr + s;
- end;
- result := HexToInt(hexstr);
- end;
-
- procedure LoadPAK;
- var i : integer;
- begin
- Blockread(F, Buf2, SizeOf(Buf2),NumRead);
- offset:= Buf2ToInt;
- Blockread(F, Buf2, SizeOf(Buf2),NumRead);
- contents:= Buf2ToInt div 64;
- if fsize >= offset + contents then
- begin
- Seek(F,offset);
- Inc(Total_Contents,Contents);
- //Set_ArchiveContentList(Total_contents,Total_Contents - Contents - 1,Total_Contents - 1);
- SetLength(Archive_Contents,Total_Contents);
- for i := 0 to contents -1 do
- begin
- Archive_Contents[i] := InitContenttype;
- with Archive_Contents[i] do
- begin
- if (sign = $4b415053) then
- begin
- BlockRead(F, Buf4, SizeOf(Buf4), NumRead);
- _Filename := Extractfilename(ModifySlash(Buf4tostr));
- _FileDefpath := Extractfilepath(ModifySlash(Buf4tostr));
- end
- else
- begin
- BlockRead(F, Buf3, SizeOf(Buf3), NumRead);
- _Filename := Extractfilename(ModifySlash(Buf3tostr));
- _FileDefpath := Extractfilepath(ModifySlash(Buf3tostr));
- end;
- loc := returnicontype(_filename);
- _Fileicon := loc;
- _FileType := Filetype.strings[loc];
- if DirectoryList.IndexOf(_FileDefPath) = -1 then
- if (_FileDefPath) <> '' then
- DirectoryList.Add(_FileDefPath);
-
- BlockRead(F, Buf2, SizeOf(Buf2), NumRead);
- _Tag := Buf2toint;
- BlockRead(F, Buf2, SizeOf(Buf2), NumRead);
- _FileSize := Buf2toInt;
- _FileArchive := Archive_List[k]._ARCname;
- end;
- end;
- end;
- end;
- Procedure LoadWAD;
- var i : integer;
- dummy : string[8];
- begin
- Blockread(F, Buf2, SizeOf(Buf2),NumRead);
- contents:= Buf2ToInt;
- Blockread(F, Buf2, SizeOf(Buf2),NumRead);
- offset:= Buf2ToInt;
-
- if fsize >= offset + contents*$20 then
- begin
- Seek(F,offset);
- Inc(Total_Contents,Contents);
- //Set_ArchiveContentList(Total_contents,Total_Contents - Contents - 1,Total_Contents - 1);;
- SetLength(Archive_Contents,Total_Contents);
- for i := 0 to contents -1 do
- begin
- Archive_Contents[i] := InitContenttype;
- with Archive_Contents[i] do
- begin
- BlockRead(F, Buf2, SizeOf(Buf2), NumRead);
- _Tag := Buf2toint;
-
- BlockRead(F, Buf2, SizeOf(Buf2), NumRead);
- _FileSize := Buf2toInt;
-
- BlockRead(F, dummy, 8, NumRead);
-
- BlockRead(F, Buf5, SizeOf(Buf5), NumRead);
- _Filename := Extractfilename(ModifySlash(Buf5tostr));
- _FileDefpath := Extractfilepath(ModifySlash(Buf5tostr));
- _FileArchive := Archive_List[k]._ARCname;
- loc := returnicontype(_filename);
- _Fileicon := loc;
- _FileType := Filetype.strings[loc];
-
- if DirectoryList.IndexOf(_FileDefPath) = -1 then
- if (_FileDefPath) <> '' then
- DirectoryList.Add(_FileDefPath);
- end;
- end;
- end;
- end;
- Procedure LoadIWAD;
- var i : integer;
- begin
- Blockread(F, Buf2, SizeOf(Buf2),NumRead);
- contents:= Buf2ToInt;
- Blockread(F, Buf2, SizeOf(Buf2),NumRead);
- offset:= Buf2ToInt;
-
- if fsize >= offset + contents*$10 then
- begin
- Seek(F,offset);
- Inc(Total_Contents,Contents);
- //Set_ArchiveContentList(Total_contents,Total_Contents - Contents - 1,Total_Contents - 1);
- SetLength(Archive_Contents,Total_Contents);
- for i := 0 to contents -1 do
- begin
- Archive_Contents[i] := InitContenttype;
- with Archive_Contents[i] do
- begin
- BlockRead(F, Buf2, SizeOf(Buf2), NumRead);
- _Tag := Buf2toint;
-
- BlockRead(F, Buf2, SizeOf(Buf2), NumRead);
- _FileSize := Buf2toInt;
-
- BlockRead(F, Buf5, 8, NumRead);
- _Filename := Extractfilename(ModifySlash(Buf5tostr));
-
- _FileDefpath := Extractfilepath(ModifySlash(Buf5tostr));
- _FileArchive := Archive_List[k]._ARCname;
-
- loc := returnicontype(_filename);
- _Fileicon := loc;
- _FileType := Filetype.strings[loc];
-
- if DirectoryList.IndexOf(_FileDefPath) = -1 then
- if (_FileDefPath) <> '' then
- DirectoryList.Add(_FileDefPath);
- end;
- end;
- end;
- end;
- Procedure LoadUNKNOWN;
- var i : integer;
- test : longint;
- recsize : longint;
- dummy : string[4];
- begin
- BlockRead(F, test, 4, NumRead);
- if (test and $ffffff) <> $464650 then exit;
-
- Blockread(F, Buf2, SizeOf(Buf2),NumRead);
- contents:= Buf2ToInt div 64;;
-
- Blockread(F, Buf2, SizeOf(Buf2),NumRead);
- recsize:= Buf2ToInt;// div 64;;
-
- Blockread(F, Buf2, SizeOf(Buf2),NumRead);
- offset:= Buf2ToInt;
-
- if fsize >= offset + contents*recsize then
- begin
- Seek(F,offset);
- Inc(Total_Contents,Contents);
- //Set_ArchiveContentList(Total_contents,Total_Contents - Contents - 1,Total_Contents - 1);
- SetLength(Archive_Contents,Total_Contents);
- for i := 0 to contents -1 do
- begin
- Archive_Contents[i] := InitContenttype;
- with Archive_Contents[i] do
- begin
-
- BlockRead(F, dummy, 4, NumRead);
-
- BlockRead(F, Buf2, SizeOf(Buf2), NumRead);
- _Tag := Buf2toint;
-
- BlockRead(F, Buf2, SizeOf(Buf2), NumRead);
- _FileSize := Buf2toInt;
- BlockRead(F, dummy, 4, NumRead);
-
- BlockRead(F, Buf5, Sizeof(Buf5), NumRead);
- _Filename := Extractfilename(ModifySlash(Buf5tostr));
- _FileDefpath := Extractfilepath(ModifySlash(Buf5tostr));
- _FileArchive := Archive_List[k]._ARCname;
- loc := returnicontype(_filename);
- _Fileicon := loc;
- _FileType := Filetype.strings[loc];
-
-
- if DirectoryList.IndexOf(_FileDefPath) = -1 then
- if (_FileDefPath) <> '' then
- DirectoryList.Add(_FileDefPath);
- end;
- end;
- end;
- end;
-
- begin
- Result := true;
- Case Processwhat of
- _LoadContents : begin
- DirectoryList.Clear;
-
- for k := processfrom to processto do
- begin
- Total_Contents := 0;
- Assignfile(f,Archive_List[k]._ARCname);
- reset(f,1);
- fsize := Filesize(f);
-
- BlockRead(F, sign, 4, NumRead);
-
- Case Sign of
- $4b434150, $4b415053 : LOADPAK;
- $32444157, $33444157 : LOADWAD;
- $44415749, $44415750 : LOADIWAD;
- else LOADUNKNOWN;
- end; //Case
- Closefile(f);
- end;
- end;
- _Extract : begin
- for i := processfrom to processto do
- begin
- Assignfile(f,Archive_List[i]._ARCname);
- reset(f,1);
- fsize := Filesize(f);
- for j := 0 to total_Contents -1 do
- if Archive_Contents[j]._FileArchive = Archive_List[i]._ARCname then
- if Archive_Contents[j]._Selected then
- begin
- with Archive_Contents[j] do
- if ExtractOptions.extr_DirNames then
- begin
- MakeDirectory(ExtractOptions.extr_to + _Filedefpath);
- Assignfile(ff,ExtractOptions.extr_to + _Filedefpath + _Filename)
- end
- else
- Assignfile(ff,ExtractOptions.extr_to + Archive_Contents[j]._Filename);
-
- Rewrite(ff,1);
- Seek(F,Archive_Contents[j]._Tag);
- fsize := Archive_Contents[j]._FileSize;
- While fsize >= sizeof(buf6) do
- begin
- BlockRead(F, Buf6, Sizeof(buf6),NumRead);
- fsize := fsize - NumRead;
- BlockWrite(FF,Buf6,Numread);
- end;
- if fsize > 0 then
- begin
- BlockRead(F, Buf6, fsize,NumRead);
- BlockWrite(FF,Buf6,Numread);
- end;
- Closefile(ff);
-
- end;
- Closefile(f);
- end;
- end;
-
-
- end;
- end;
- function TCakDir.ProcessCAB(processwhat : worktype) : boolean;
- var i,j : integer;
- afilelist, apathlist : TStrings;
- begin
- Result := true;
- Load_CAB_DLL;
- case ProcessWhat of
- _LoadContents : begin
- Cabmode := _CFList;
- Total_Contents := 0;
- DirectoryList.Clear;
- for i := processfrom to processto do
- begin
- processing := i;
- CabRDir.ExtractFiles(Archive_List[i]._ARCname,GrabTempPath,_O_RDWR);
- end;
- end;
- _Extract : begin
- Cabmode := _CFExtract;
- for i := processfrom to processto do
- if Get_Selected_Count(Archive_List[i]._ARCname) > 0 then
- begin
- processing := i;
- Cab_Extr_to := NewTempPath;
- TotalProgress := 0;
- For j := 0 to Total_Contents -1 do
- if Archive_Contents[j]._Selected then
- if not directoryexists(Cab_Extr_to + Archive_Contents[j]._FileDefPath) then
- MakeDirectory(Cab_Extr_to + Archive_Contents[j]._FileDefPath);
-
- CabRDir.ExtractFiles(Archive_List[i]._ARCname,Cab_Extr_to,0);
- UNLoad_Cab_DLL;
- For j := 0 to Total_Contents -1 do
- if Archive_Contents[j]._Selected then
- with Archive_Contents[j] do
- if fileexists(Cab_Extr_to + _FileDefpath + _FileName) then
- if Extractoptions.extr_DirNames = true then
- begin
- if not DirectoryExists(Extractoptions.extr_to + _FileDefpath) then
- MakeDirectory(Extractoptions.extr_to + _FileDefpath);
- MoveFile(PChar(Cab_Extr_to + _FileDefpath + _FileName),Pchar(Extractoptions.extr_to + _FileDefpath + _FileName));
- end else
- MoveFile(PChar(Cab_Extr_to + _FileDefpath + _FileName),Pchar(Extractoptions.extr_to + _FileName));
-
- For j := 0 to Total_Contents -1 do
- if Archive_Contents[j]._Selected then
- with Archive_Contents[j] do
- if directoryexists(Cab_Extr_to + _FileDefpath) then
- RemoveDirectory(PChaR(Cab_Extr_to + _FileDefPath));
-
- RemoveDirectory(PChar(Cab_Extr_to));
- end;
- end;
- _Test : begin
- Add_All_Selected_List;
- Cabmode := _CFExtract;
- for i := processfrom to processto do
- begin
- processing := i;
- Cab_Extr_to := NewTempPath;
- MakeDirectory(Cab_Extr_to);
- TotalProgress := 0;
- For j := 0 to Total_Contents -1 do
- if Archive_Contents[j]._Selected then
- if not directoryexists(Cab_Extr_to + Archive_Contents[j]._FileDefPath) then
- MakeDirectory(Cab_Extr_to + Archive_Contents[j]._FileDefPath);
-
- CabRDir.ExtractFiles(Archive_List[i]._ARCname,Cab_Extr_to,0);
- UNLoad_Cab_DLL;
-
- For j := 0 to Total_Contents -1 do
- if Archive_Contents[j]._Selected then
- with Archive_Contents[j] do
- begin
-
- if fileexists(Cab_Extr_to + _FileDefpath + _FileName) then
- begin
- if assigned(FOnMsg) then
- FOnMsg(nil,0, _FileDefpath + _Filename + ' OK');
- end else
- if assigned(FOnMsg) then
- FOnMsg(nil,0, _FileDefpath + _Filename + ' FAIL');
- end;
-
- For j := 0 to Total_Contents -1 do
- if Archive_Contents[j]._Selected then
- with Archive_Contents[j] do
- if fileexists(Cab_Extr_to + _FileDefpath + _FileName) then
- Deletefile(PChar(Cab_Extr_to + _FileDefpath + _FileName));
-
-
- For j := 0 to Total_Contents -1 do
- if Archive_Contents[j]._Selected then
- with Archive_Contents[j] do
- if directoryexists(Cab_Extr_to + _FileDefpath) then
- RemoveDirectory(PChaR(Cab_Extr_to + _FileDefPath));
-
- RemoveDirectory(PChar(Cab_Extr_to));
- end;
-
- end;
-
- _Add : begin
- if total_contents > 0 then
- if MessageDlg('Are you sure? Origional Cab content will be removed!', mtWarning, [mbYes, mbNo], 0) = MrNo then
- exit;
-
- afilelist := TStringList.create;
- afilelist.clear;
- apathlist := TStringList.create;
- apathlist.clear;
- TotalProgress := 0;
- try
- //if then
- for i := 0 to AddOptions.Add_files.Count -1 do
- afilelist.AddStrings(pollfilelist(Addoptions.add_files.strings[i],Addoptions.add_SubDir));
- AddOptions.Add_files.clear;
- AddOptions.Add_files.addstrings(afilelist);
- afilelist.clear;
-
- For i := 0 to AddOptions.add_exclude.Count -1 do
- begin
- j := AddOptions.Add_files.Indexof(AddOptions.add_exclude.Strings[i]);
- if j <> -1 then AddOptions.Add_files.Delete(j);
- end;
-
- For i := 0 to Addoptions.add_files.count -1 do
- begin
- afilelist.Add(Addoptions.add_files.strings[i]);
- apathlist.Add(Extractfilename(Addoptions.add_files.strings[i]));
- end;
-
- CabWDir.Open(Archive_List[Addoptions.add_to]._ARCName,'Disk',0 ,900000,60);
-
- For i := 0 to afilelist.count -1 do
- if Addoptions.add_usepath then
- CabWDir.AddFile(afilelist.strings[i],modifyslash(removedrive(afilelist.strings[i]),'\','/'),[],MakeLzxcompression(21)) else
- CabWDir.AddFile(afilelist.strings[i],apathlist.strings[i],[],MakeLzxcompression(21));
-
- CabWDir.FlushCabinet(True);
- CabWDir.Close;
-
- finally
- afilelist.free;
- apathlist.free;
- end;
- end;
-
- Else Result := false;
- end;
- end;
-
- function TCakDir.ProcessEXT(processwhat : worktype) : boolean;
- var i,loc : integer;
- begin
- Load_EXT_DLL;
- result := true;
- Case Processwhat of
- _LoadContents : begin
- CakExt.Process(Archive_list[0]._Arcname,Ex_LoadContents);
- Total_Contents := Cakext.Total_Contents;
- Setlength(Archive_Contents,Total_Contents);
- for i := 0 to cakext.Total_Contents - 1 do
- begin
- Archive_Contents[i]._Filename := extractfilename(cakext.Archive_Contents[i]._Filename);
- Archive_Contents[i]._Filedefpath := extractfilepath(cakext.Archive_Contents[i]._Filename);
- loc := returnicontype(Archive_Contents[i]._Filename);
- Archive_Contents[i]._Fileicon := loc;
- Archive_Contents[i]._FileType := Filetype.strings[loc];
- Archive_Contents[i]._FileSize := cakext.Archive_Contents[i]._FileSize;
- Archive_Contents[i]._FilePackedSize := cakext.Archive_Contents[i]._FilePackedSize;
- Archive_Contents[i]._FileRatio := cakext.Archive_Contents[i]._FileRatio;
- Archive_Contents[i]._Filetime := now;
- Archive_Contents[i]._FileCRC := '000000';
- end;
- end;
- _Add : begin
- for i := 0 to AddOptions.add_files.count -1 do
- begin
- CakExt.AddOptionsEx.add_files := AddOptions.add_files.strings[i];
- CakExt.Process(Archive_list[0]._Arcname,Ex_Add);
- end;
-
- end;
- _Extract : begin
- CakExt.ExtractOptionsEx.extr_to := ExtractOptions.extr_to;
- if Get_Selected_Count = Total_Contents then
- begin
- CakExt.ExtractOptionsEx.extract_files := '*.*';
- CakExt.Process(Archive_list[0]._Arcname,Ex_Extract);
- end else
- begin
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- begin
- CakExt.ExtractOptionsEx.extract_files := Archive_Contents[i]._FileDefPath + Archive_Contents[i]._FileName;
- CakExt.Process(Archive_list[0]._Arcname,Ex_Extract);
- end;
-
- end;
-
- end;
- _SFX : begin
- CakExt.Process(Archive_list[0]._Arcname,Ex_SFX);
- end;
-
- _TEST : begin
- CakExt.Process(Archive_list[0]._Arcname,Ex_TEST);
- end;
-
- _DELETE : begin
- CakExt.Process(Archive_list[0]._Arcname,Ex_DELETE);
- end;
- end;
- if assigned(FOnMsg) then
- for i := 0 to cakext.DosOutput.count -1 do
- FOnMsg(nil,0,cakext.dosoutput.strings[i]);
-
- end;
-
- {$IFDEF USE_ARC}
- function TCakDir.ProcessARC(processwhat : worktype) : boolean;
- var i,j, done : integer;
- IndivisualInfo:TIndivisualInfo;
- sfiles : TStrings;
- k,dummy : string;
- CABDIR : TCAB32;
- afilelist : tstrings;
- function ReturnarchiveType(filename : string) : TArchiverType;
- begin
- k := Uppercase(extractfileext(filename));
- if k = '.ZIP' then
- Result := atZip else
- if (k = '.LZH') or (k = '.LHA') then
- Result := atLha else
- if k = '.CAB' then
- Result := atCab else
- if k = '.TAR' then
- Result := atTar else
- if (k = '.TAZ') or (k = '.TGZ') or
- (k = '.GZ') or (k = '.Z') then
- Result := atTgz else
- if k = '.BZ2' then
- Result := atBz2 else
- if k = '.RAR' then
- Result := atRar else
- if (k = '.BGA') or (k = 'BZA') or (k = '.GZA') then
- Result := atBga else
- if k = '.YZ1' then
- Result := atYz1 else
- if k = '.BEL' then
- Result := atBel else
- if k = '.GCA' then
- Result := atGca else
- Result := atAutoDetect;
- end;
- begin
- result := false;
- Load_ARC_DLL;
- Timer1.Enabled := true;
- ArcDir.Options.n := 0; {Showing Extracting Dialog}
- ArcDir.OutputSize := 8192;
- Case ProcessWhat of
- _SFX : begin
- ArcDir.Options.gw := 3;
- Arcdir.FileName := Archive_List[sfxoptions.sfx_to]._arcname;
- k := extractfilepath(Archive_List[sfxoptions.sfx_to]._arcname);
- ArcHandleError(Arcdir.MakeSfx(Application.handle,nil,k));
- end;
- _LoadContents : begin
- DirectoryList.clear;
- Total_Contents := -1;
- for i := processfrom to processto do
- begin
- processing := i;
- ArcDir.FileName:= Archive_List[i]._ARCname;
- ArcDir.FindOpen(Application.handle,0 );
- ArcDir.ArchiverType := ReturnarchiveType(Archive_List[i]._ARCname);
- done := ArcDir.FindFirst( '*.*',IndivisualInfo );
- while done = 0 do
- begin
- Inc(Total_Contents);
- SetLength(Archive_Contents,Total_Contents + 1);
- with Archive_Contents[Total_Contents] do
- begin
- _Filename := Extractfilename(modifyslash(IndivisualInfo.szFileName));
- _FileICON := returnicontype(_Filename);
- _Filetype := Filetype.strings[_Fileicon];
- _FileRatio := IndivisualInfo.wRatio;
- _encrypted := False;
- _FileSize := IndivisualInfo.dwOriginalSize;
- _FilePackedSize :=IndivisualInfo.dwCompressedSize;
- _FileTime := DosDateTimeToDateTime(IndivisualInfo.wDate,IndivisualInfo.wtime);
- _FileCRC := InttoHex(IndivisualInfo.dwCRC,8);
- _FileDefPath := Extractfilepath(modifyslash(IndivisualInfo.szFileName));
- if DirectoryList.IndexOf(_FileDefPath) = -1 then
- if (_FileDefPath) <> '' then
- DirectoryList.Add(_FileDefPath);
- _FileArchive := Archive_List[i]._ARCname;
- end;
- done := ArcDir.FindNext(IndivisualInfo);
- end;
- Inc(Total_Contents);
- end;
- ArcDir.FindClose;
- end;
- _Add : begin
- TotalSize := 0;
- ArcDir.Options.a := 1;
- ArcDir.FileName := Archive_List[addoptions.add_to]._ARCname;
- ArcDir.ArchiverType := ReturnarchiveType(Archive_List[addoptions.add_to]._ARCname);
- afilelist := TStringlist.create;
- sfiles := TStringlist.create;
- try
- if Addoptions.add_usepath then
- ArcDir.Options.x := 1
- else
- ArcDir.Options.x := 0;
-
- for i := 0 to AddOptions.Add_files.Count -1 do
- afilelist.addstrings(pollfilelist(Addoptions.add_files.strings[i],Addoptions.add_SubDir));
-
- Addoptions.add_files.clear;
- Addoptions.add_files.AddStrings(afilelist);
-
- For i := 0 to AddOptions.add_exclude.Count -1 do
- begin
- j := AddOptions.Add_files.Indexof(AddOptions.add_exclude.Strings[i]);
- if j <> -1 then AddOptions.Add_files.Delete(j);
- end;
-
- if ArcDir.ArchiverType = atCAB then {this code let you add more than 1 file @ a time}
- begin
- k := '-a -mx';
- k := space + '"' + ArcDir.Filename + '"';
- for i := 0 to Addoptions.add_files.Count - 1 do
- k := k + space + '"' + Addoptions.add_files.strings[i] + '"';
- CabDir := TCab32.Create;
- try
- CabDir.Cab(application.handle,k,dummy);
- finally
- CabDir.Free;
- end;
- end
- else
- if (ArcDir.ArchiverType = atTgz) or (ArcDir.ArchiverType = atTar) then
- begin
- sfiles.clear;
- for i := 0 to Addoptions.add_files.Count - 1 do
- sfiles.Add(Addoptions.add_files.strings[i]);
-
- ArcHandleError(ArcDir.PackFiles(Application.Handle, nil,
- '', [sfiles]));
- end else
- for i := 0 to Addoptions.add_files.Count - 1 do
- begin
- sfiles.Clear;
- sfiles.Add(Extractfilename(Addoptions.add_files.strings[i]));
-
- ArcHandleError(ArcDir.PackFiles(Application.Handle, nil,
- Extractfilepath(Addoptions.add_files.Strings[i]), [sfiles]));
- end;
- finally
- sfiles.free;
- end;
-
- end;
- _Extract : For j := processfrom to processto do
- if Get_Selected_Count(Archive_List[j]._ARCname) > 0 then
- begin
- TotalSize := 0;
- sfiles := TStringlist.create;
- try
- ArcDir.Filename := Archive_List[j]._ARCname;
- if ExtractOptions.extr_Dirnames then
- ArcDir.Options.x := 1 else
- ArcDir.Options.x := 0;
- sfiles.Clear;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- if Archive_Contents[i]._FileArchive = Archive_List[j]._ARCname then
- sfiles.Add(Archive_Contents[i]._Filedefpath + Archive_Contents[i]._Filename);
-
- for i := sfiles.count -1 downto 0 do
- if fileexists(Appendslash(ExtractOptions.extr_to) + sfiles.strings[i]) then
- if AskOverwrite(sfiles.strings[i]) then
- Deletefile(ExtractOptions.extr_to + sfiles.strings[i]) else
- sfiles.Delete(i);
-
- ArcHandleError(ArcDir.UnpackFiles(Application.handle,nil,ExtractOptions.extr_to,[sfiles]));
- finally
- sfiles.free;
- end;
- end;
- _Delete : For j := processfrom to processto do
- begin
- TotalSize := 0;
- sfiles := TStringlist.create;
- try
- ArcDir.Filename := Archive_List[j]._ARCname;
- if ExtractOptions.extr_Dirnames then
- ArcDir.Options.x := 1 else
- ArcDir.Options.x := 0;
- sfiles.Clear;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- if Archive_Contents[i]._FileArchive = Archive_List[j]._ARCname then
- begin
- sfiles.clear;
- sfiles.Add(Archive_Contents[i]._Filedefpath + Archive_Contents[i]._Filename);
- ArcHandleError(ArcDir.Removeitems(Application.handle,nil,Archive_Contents[i]._FileDefPath ,[sfiles]));
- end;
- finally
- sfiles.free;
- end;
- end;
- _Test : For j := processfrom to processto do
- begin
- ArcDir.Filename := Archive_List[j]._ARCname;
- ARCHandleError(ArcDir.CheckArchive( CHECKARCHIVE_FULLCRC,0 ));
- //ARCHandleError(ArcDir.UnpackFiles( Application.Handle,nil,'TEST\',[nil] ));
- end;
-
- end;
- Timer1.Enabled := false;
- end;
- {$ENDIF}
-
- {$IFDEF USE_ACE2}
- procedure TCakdir.Ace2HandleError(ErrNo : integer);
- begin
- if Ace2Msg <> '' then
- if assigned(FOnMsg) then
- FOnMsg(nil,Ace2Code,Ace2Msg);
- if assigned(FOnMsg) then
- Case ErrNo of
- ACE_ERROR_NOERROR : FOnMsg(nil,ErrNo,'OK');
- ACE_ERROR_MEM : FOnMsg(nil,ErrNo,'our of memory');
- ACE_ERROR_FILES : FOnMsg(nil,ErrNo,'no files specified');
- ACE_ERROR_FOUND : FOnMsg(nil,ErrNo,'specified archive not found');
- ACE_ERROR_FULL : FOnMsg(nil,ErrNo,'disk full');
- ACE_ERROR_OPEN : FOnMsg(nil,ErrNo,'could not open file');
- ACE_ERROR_READ : FOnMsg(nil,ErrNo,'read error');
- ACE_ERROR_WRITE : FOnMsg(nil,ErrNo,'write error');
- ACE_ERROR_CLINE : FOnMsg(nil,ErrNo,'invalid command line');
- ACE_ERROR_CRC : FOnMsg(nil,ErrNo,'CRC error');
- ACE_ERROR_OTHER : FOnMsg(nil,ErrNo,'other error');
- ACE_ERROR_EXISTS : FOnMsg(nil,ErrNo,'file already exists');
- ACE_ERROR_USER : FOnMsg(nil,ErrNo,'user terminate');
- end;
- end;
- {$ENDIF}
-
- {$IFDEF USE_ACE}
- function TCakDir.ProcessACE(processwhat : worktype) : boolean;
- var i,j: integer;
- begin
- result := false;
- Load_ACE_DLL;
- Case Processwhat of
- _LoadContents : begin
- Total_Contents := -1;
- for i := processfrom to processto do
- begin
- processing := i;
- Acedir.Archivefilename := Archive_List[i]._ARCname;
- j := Acedir.ListArchive;
- if j = 0 then result := true else
- result := false;
- Inc(Total_Contents)
- end;
- end;
- _Extract : begin
- {$IFDEF USE_ACE2}
- For j := processfrom to processto do
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected and (Archive_Contents[i]._FileArchive = Archive_List[j]._ARCname) then
- begin
- Strcopy(UnaceV2.FileList,Pchar(Archive_Contents[i]._Filedefpath +
- Archive_Contents[i]._Filename));
- Ace2Msg := '';
- Ace2HandleError(CallACEExtract(Archive_List[j]._ARCname,
- ExtractOptions.extr_to,
- Password,
- not ExtractOptions.extr_DirNames));
- end;
- {$ELSE}
- Acedir.TargetDirectory := ExtractOptions.extr_to;
-
- For j := processfrom to processto do
- if Get_Selected_Count(Archive_List[j]._ARCname) > 0 then
- begin
- Acedir.Archivefilename := Archive_List[j]._ARCname;
- Acedir.FilesToProcess.Clear;
- for i := 0 to Total_Contents -1 do
- if Archive_Contents[i]._Selected then
- if Archive_Contents[i]._FileArchive = Archive_List[j]._ARCname then
- Acedir.FilesToProcess.Add(Archive_Contents[i]._Filedefpath + Archive_Contents[i]._Filename);
-
- i := Acedir.ExtractArchive;
- if i= 0 then result := true else
- if Assigned( FOnMsg ) then
- FOnMsg(nil,i,Acedir.GetAceErrorString(i));
- end;
- {$ENDIF}
- end;
- _Test : {$IFDEF USE_ACE2}
- For j := processfrom to processto do
- begin
- Ace2Msg := '';
- Ace2HandleError(CallACETest(Archive_List[j]._ARCname));
- end;
- {$ELSE}
- for i := processfrom to processto do
- begin
- processing := i;
- Acedir.Archivefilename := Archive_List[i]._ARCname;
- j := Acedir.TestArchive;
- if j = 0 then result := true else
- if Assigned( FOnMsg ) then
- FOnMsg(nil,i,Acedir.GetAceErrorString(j));
- end;
- {$ENDIF}
- else if Assigned( FOnMsg ) then
- FOnMsg( nil, 0, FUNCNOTAVIL );
- end;
-
-
- end;
- {$ENDIF}
-
- {$IFDEF USE_ARC}
- procedure TCakDir.Load_ARC_DLL;
- begin
- if not assigned(ArcDir) then
- Arcdir := TArchiveFile.Create(Application);
- ArcDir.OnProgress := ArcDirProgress;
- end;
- {$ENDIF}
- {$IFDEF USE_ARC}
- procedure TCakDir.UnLoad_ARC_DLL;
- begin
- //if assigned(Arcdir) then //Crash here...
- // Arcdir.Free;
- //Arcdir := nil;
- end;
- {$ENDIF}
-
- {$IFDEF USE_ZIP}
- procedure TCakDir.ZipDirMessage(Sender: TObject; ErrCode: integer;
- Message: string);
- begin
- if Assigned( FOnMsg ) then
- FOnMsg(Sender, Errcode, Message);
- end;
- {$ENDIF}
-
-
- {$IFDEF USE_ZIP}
- procedure TCakDir.ZipDirExtrOver(Sender: TObject;
- ForFile: String; Older: Boolean; var DoOverwrite: Boolean; DirIndex: Integer);
- begin
- DoOverwrite := AskOverwrite(Forfile);
- end;
- {$ENDIF}
-
- {$IFDEF USE_ZIP}
- procedure TCakDir.ZipDirProgress(Sender: TObject; ProgrType: ProgressType;
- Filename: string; FileSize: integer);
- begin
- case ProgrType of
- TotalSize2Process:
- TotalProgress := 0;
- ProgressUpdate:
- TotalProgress := TotalProgress + FileSize;
- end;
- if Assigned( FOnProg ) then
- FOnProg(Sender,filename, Filesize,TotalProgress);
- end;
- {$ENDIF}
-
- {$IFDEF USE_ZIP}
- procedure TCakDir.ZipDirPwdErr(Sender: TObject;
- IsZipAction: Boolean; var NewPassword: String; ForFile: String;
- var RepeatCount: Cardinal; var Action: TPasswordButton);
- var pwd : string;
- begin
- if (password <> pwd) and (password <> '') then
- begin
- newpassword := password;
- RepeatCount := 1;
- end
- else
- begin
- if assigned(FOnPwd) then
- FOnPwd(nil,zipdir.ZipFileName,forfile,pwd) else
- pwd := Inputbox(MSG_PWD, MSG_PLZENTERPWD4 + forfile, pwd);
- zipdir.Password := pwd;
- Newpassword := pwd;
- RepeatCount := 0;
- end;
- end;
- {$ENDIF}
-
- {$IFDEF USE_RS}
- Procedure TCakDir.RsDirAddLog(Sender: TObject; s: String);
- begin
- if Assigned( FOnMsg ) then
- FOnMsg(Sender,0,s);
- end;
- {$ENDIF}
- {$IFDEF USE_RS}
- Procedure TCakDir.RsDirCDChange(Sender: TObject);
- var
- i, loc: integer;
- CentralFileHeader: TCentralFileHeader;
- ColMan: TObjList;
- k: string;
- begin
- ColMan := TObjList.Create;
- ColMan.Add(TNameColDataExtr.Create);
- ColMan.Add(TSizeColDataExtr.Create);
- ColMan.Add(TTypeNameColDataExtr.Create);
- ColMan.Add(TRatioColDataExtr.Create);
- ColMan.Add(TPackedColDataExtr.Create);
- ColMan.Add(TTimeColDataExtr.Create);
- ColMan.Add(TNumBlocksColDataExtr.Create);
- with RsDir.ArchiveMan.ArchiveFile do
- begin
- Total_Contents := CentralDir.Count;
- SetLength(Archive_Contents, Total_Contents);
- for i := 0 to CentralDir.Count - 1 do
- with Archive_Contents[i] do
- begin
- CentralFileHeader := TCentralFileHeader(CentralDir[i]);
- _Filename := Extractfilename(TColDataExtr(ColMan[0]).Extract(CentralFileHeader));
- _Filedefpath := Extractfilepath(TColDataExtr(ColMan[0]).Extract(CentralFileHeader));
- loc := returnicontype(_filename);
- _Filetype := Filetype.strings[loc];
- _FileIcon := loc;
- _FileSize := strtointdef(TColDataExtr(ColMan[1]).Extract(CentralFileHeader), 1);
- _FilePackedSize := strtointdef(TColDataExtr(ColMan[4]).Extract(CentralFileHeader),
- 1);
- _FileRatio := trunc((_FilePackedSize / _FileSize) * 100);
- _FileArchive := Archive_List[0]._ARCname;
- k := TColDataExtr(ColMan[5]).Extract(CentralFileHeader);
- if k <> '' then
- _fileTime := StrtoDatetime(k);
-
- end;
- end;
- ColMan.Free;
- end;
-
- {$ENDIF}
-
- {$IFDEF USE_INDY}
- function TCakDir.ProcessUUE(processwhat : worktype) : boolean;
- var IDUUDecoder1 : TIDUUDecoder;
- IDUUEncoder1 : TIDUUEncoder;
- s,k,x : string;
- t : array[0..44] of Char;
- tf : textfile;
- fn : string;
- loc,i,fz,count : integer;
- bf : file;
- Fs : TFileStream;
- begin
- result := true;
- Case processwhat of
- _LoadContents : begin
- Total_Contents := 0;
- For i := processfrom to processto do
- begin
- Assignfile(tf,Archive_List[i]._arcname);
- Reset(tf);
- fz := Filesize(tf);
- fn := '';
- IDUUDecoder1 := TIDUUDecoder.Create(nil);
-
- with IDUUDecoder1 do
- begin
- AutocompleteInput := False;
- Reset;
- while not eof(tf) and (fn = '') do
- begin
- readln(tf,k);
- s := CodeString(k+#13);
- s := CompletedInput;
- s := CompletedInput;
- if filename <> '' then fn := filename;
- end;
- end;
- Closefile(tf);
- IDUUDecoder1.free;
-
- Inc(Total_Contents);
- SetLength(Archive_Contents,Total_Contents);
- Archive_Contents[Total_Contents-1]._Filename := fn;
- loc := returnicontype(fn);
- Archive_Contents[Total_Contents-1]._Fileicon := loc;
- Archive_Contents[Total_Contents-1]._FileType := Filetype.strings[loc];
-
- Archive_Contents[Total_Contents-1]._FileRatio := 100;
- Archive_Contents[Total_Contents-1]._encrypted := FALSE;
- Archive_Contents[Total_Contents-1]._FileSize := fz;
- Archive_Contents[Total_Contents-1]._FilePackedSize := fz;
- Archive_Contents[Total_Contents-1]._FileCRC := '';
- Archive_Contents[Total_Contents-1]._FileDefPath := '';
- Archive_Contents[Total_Contents-1]._FileArchive := Archive_List[i]._ARCname;
- end;
- end;
- _Extract : begin
-
- For i := processfrom to processto do
- if Archive_Contents[i]._Selected then
- begin
- Assignfile(tf,Archive_List[i]._arcname);
- Reset(tf);
- fn := '';
- IDUUDecoder1 := TIDUUDecoder.Create(nil);
- with IDUUDecoder1 do
- begin
- while not eof(tf) and (fn = '') do
- begin
- AutocompleteInput := False;
- Reset;
- readln(tf,k);
-
- if Uppercase(k) = 'TABLE' then
- begin
- x := '';
- s := '';
- While not eof(tf) and not (Uppercase(Copy(s,0,9)) = 'BEGIN 644') do
- begin
- x := x + s;
- readln(tf,s);
- end;
- SetCodingtable(x);
- k := s;
- end;
-
- if Uppercase(Copy(k,0,9)) = 'BEGIN 644' then
- begin
- s := CodeString(k+#13);
- s := CompletedInput;
- s := CompletedInput;
- if filename <> '' then fn := filename;
- end;
- end;
-
- s := Appendslash(extractoptions.extr_to) + fn;
- AssignFile(bf, s);
- Rewrite(bf,1);
-
- While not eof(tf) do
- begin
- Readln(tf,k);
- k := CodeString(k +#13#10);
- Fetch(k, ';');
- BlockWrite(bf, k[1], Length(k));
- end;
-
- repeat
- k := CompletedInput;
- Fetch(k, ';');
- BlockWrite(bf, k[1], Length(k));
- until k = '';
- end;
-
- Closefile(tf);
- Closefile(bf);
- IDUUDecoder1.free;
- end;
- end;
- _Add : begin
- IDUUEncoder1 := TIDUUEncoder.Create(nil);
- Fs := TFileStream.Create(Addoptions.add_files.Strings[0], fmOPENREAD);
- with IDUUEncoder1 do
- begin
- AutocompleteInput := False;
- Reset;
- Filename := Extractfilename(Addoptions.add_files.strings[0]);
- AssignFile(tf, Archive_List[0]._arcname);
- Rewrite(tf);
- writeln(tf,'table');
- i := length(IDUUEncoder1.CodingTable) div 2;
- Writeln(tf,Copy(IDUUEncoder1.CodingTable,0,i));
- Writeln(tf,Copy(IDUUEncoder1.CodingTable,i+1,length(IDUUEncoder1.CodingTable)-i));
- Repeat
- count := fs.Read(t,45);
- SetBufferSize(count);
- s := CodeString(t);
- Fetch(s, ';');
- write(tf, s);
- Until count < 45;
- s := CompletedInput;
- Fetch(s, ';');
- if s <> '' then write(tf, s);
- Free;
-
- Closefile(tf);
- Fs.Free;
- end;
- end;
- {
- _Add : begin
- IDUUEncoder1 := TIDUUEncoder.Create(nil);
- with IDUUEncoder1 do
- begin
- AutocompleteInput := False;
- filter := DEFAULTFILTER;
- Reset;
- SetCodingtable(filter);
- AssignFile(bf, Addoptions.add_files.Strings[0]);
- System.Reset(bf, 1);
- Filename := Extractfilename(Addoptions.add_files.strings[0]);
- AssignFile(tf, Archive_List[0]._arcname);
- Rewrite(tf);
- SetLength(t, 45);
- BlockRead(bf, t[1], 45, count);
- SetLength(t, count);
- while count > 0 do
- begin
- // set coding buffer size to the number of bytes read (up to 45)
- SetBufferSize(Length(t));
- s := CodeString(t);
- Fetch(s, ';');
- if s <> '' then
- write(tf, s);
- BlockRead(bf, t[1], 45, count);
- SetLength(t, count);
- end;
-
- // to end coding and get an "end" line
- s := CompletedInput;
- Fetch(s, ';');
- if s <> ''
- then write(tf, s);
- Free;
- end;
- CloseFile(bf);
- CloseFile(tf);
- end;
- }
- end;
- end;
- {$ENDIF}
-
- {$IFDEF USE_INDY}
- function TCakDir.ProcessXXE(processwhat : worktype) : boolean;
- var IDXXDecoder1 : TIDXXDecoder;
- // IDXXEncoder1 : TIDXXEncoder;
- s,k,x : string;
- // t : array[0..44] of Char;
- tf : textfile;
- fn : string;
- loc,i,fz{,count} : integer;
- bf : file;
- //Fs : TFileStream;
- begin
- result := true;
- Case processwhat of
- _LoadContents : begin
- Total_Contents := 0;
- For i := processfrom to processto do
- begin
- Assignfile(tf,Archive_List[i]._arcname);
- Reset(tf);
- fz := Filesize(tf);
- fn := '';
- IDXXDecoder1 := TIDXXDecoder.Create(nil);
-
- with IDXXDecoder1 do
- begin
- AutocompleteInput := False;
- Reset;
- while not eof(tf) and (fn = '') do
- begin
- readln(tf,k);
- s := CodeString(k+#13);
- s := CompletedInput;
- s := CompletedInput;
- if filename <> '' then fn := filename;
- end;
- end;
- Closefile(tf);
- IDXXDecoder1.free;
-
- Inc(Total_Contents);
- SetLength(Archive_Contents, Total_Contents);
- Archive_Contents[Total_Contents-1]._Filename := fn;
- loc := returnicontype(fn);
- Archive_Contents[Total_Contents-1]._Fileicon := loc;
- Archive_Contents[Total_Contents-1]._FileType := Filetype.strings[loc];
-
- Archive_Contents[Total_Contents-1]._FileRatio := 100;
- Archive_Contents[Total_Contents-1]._encrypted := FALSE;
- Archive_Contents[Total_Contents-1]._FileSize := fz;
- Archive_Contents[Total_Contents-1]._FilePackedSize := fz;
- Archive_Contents[Total_Contents-1]._FileCRC := '';
- Archive_Contents[Total_Contents-1]._FileDefPath := '';
- Archive_Contents[Total_Contents-1]._FileArchive := Archive_List[i]._ARCname;
- end;
- end;
- _Extract : begin
-
- For i := processfrom to processto do
- if Archive_Contents[i]._Selected then
- begin
- Assignfile(tf,Archive_List[i]._arcname);
- Reset(tf);
- fn := '';
- IDXXDecoder1 := TIDXXDecoder.Create(nil);
- with IDXXDecoder1 do
- begin
- while not eof(tf) and (fn = '') do
- begin
- AutocompleteInput := False;
- Reset;
- readln(tf,k);
-
- if Uppercase(k) = 'TABLE' then
- begin
- x := '';
- s := '';
- While not eof(tf) and not (Uppercase(Copy(s,0,9)) = 'BEGIN 644') do
- begin
- x := x + s;
- readln(tf,s);
- end;
- SetCodingtable(x);
- k := s;
- end;
-
- if Uppercase(Copy(k,0,9)) = 'BEGIN 644' then
- begin
- s := CodeString(k+#13);
- s := CompletedInput;
- s := CompletedInput;
- if filename <> '' then fn := filename;
- end;
- end;
-
- s := Appendslash(extractoptions.extr_to) + fn;
- AssignFile(bf, s);
- Rewrite(bf,1);
-
- While not eof(tf) do
- begin
- Readln(tf,k);
- k := CodeString(k +#13#10);
- Fetch(k, ';');
- BlockWrite(bf, k[1], Length(k));
- end;
-
- repeat
- k := CompletedInput;
- Fetch(k, ';');
- BlockWrite(bf, k[1], Length(k));
- until k = '';
- end;
-
- Closefile(tf);
- Closefile(bf);
- IDXXDecoder1.free;
- end;
- end;
- end;
- end;
- {$ENDIF}
-
- {$IFDEF USE_INDY}
- function TCakDir.ProcessB64(processwhat : worktype) : boolean;
- var IDBase64Decoder1 : TIDBase64Decoder;
- // IDXXEncoder1 : TIDXXEncoder;
- s,k : string;
- // t : array[0..44] of Char;
- tf : textfile;
- fn : string;
- loc,i,fz{,count} : integer;
- bf : file;
- //Fs : TFileStream;
- begin
- result := true;
- Case processwhat of
- _LoadContents : begin
- Total_Contents := 0;
- For i := processfrom to processto do
- begin
- Assignfile(tf,Archive_List[i]._arcname);
- Reset(tf);
- fz := Filesize(tf);
- fn := '';
- IDBase64Decoder1 := TIDBase64Decoder.Create(nil);
-
- with IDBase64Decoder1 do
- begin
- AutocompleteInput := False;
- Reset;
- while not eof(tf) and (fn = '') do
- begin
- readln(tf,k);
- s := CodeString(k+#13);
- s := CompletedInput;
- s := CompletedInput;
- if filename <> '' then fn := filename;
- end;
- end;
- Closefile(tf);
- IDBase64Decoder1.free;
-
- Inc(Total_Contents);
- SetLength(Archive_Contents, Total_Contents);
- Archive_Contents[Total_Contents-1]._Filename := fn;
- loc := returnicontype(fn);
- Archive_Contents[Total_Contents-1]._Fileicon := loc;
- Archive_Contents[Total_Contents-1]._FileType := Filetype.strings[loc];
-
- Archive_Contents[Total_Contents-1]._FileRatio := 100;
- Archive_Contents[Total_Contents-1]._encrypted := FALSE;
- Archive_Contents[Total_Contents-1]._FileSize := fz;
- Archive_Contents[Total_Contents-1]._FilePackedSize := fz;
- Archive_Contents[Total_Contents-1]._FileCRC := '';
- Archive_Contents[Total_Contents-1]._FileDefPath := '';
- Archive_Contents[Total_Contents-1]._FileArchive := Archive_List[i]._ARCname;
- end;
- end;
- _Extract : begin
-
- For i := processfrom to processto do
- if Archive_Contents[i]._Selected then
- begin
- Assignfile(tf,Archive_List[i]._arcname);
- Reset(tf);
- fn := '';
- IDBase64Decoder1 := TIDBase64Decoder.Create(nil);
- with IDBase64Decoder1 do
- begin
- readln(tf,k);
- s := CodeString(k+#13);
- s := CompletedInput;
- s := CompletedInput;
- if filename <> '' then fn := filename;
-
- s := Appendslash(extractoptions.extr_to) + fn;
- AssignFile(bf, s);
- Rewrite(bf,1);
-
- While not eof(tf) do
- begin
- Readln(tf,k);
- k := CodeString(k +#13#10);
- Fetch(k, ';');
- BlockWrite(bf, k[1], Length(k));
- end;
-
- repeat
- k := CompletedInput;
- Fetch(k, ';');
- BlockWrite(bf, k[1], Length(k));
- until k = '';
- end;
-
- Closefile(tf);
- Closefile(bf);
- IDBase64Decoder1.free;
- end;
- end;
- end;
- end;
- {$ENDIF}
-
- {$IFDEF USE_ZIP}
- procedure TCakDir.Load_ZIP_DLL;
- begin
- if assigned(Zipdir) then exit;
- Zipdir := TZipMaster.Create(self);
- Zipdir.OnProgress := ZipDirProgress;
- Zipdir.OnMessage := ZipDirMessage;
- Zipdir.OnPasswordError := ZipDirPwdErr;
- Zipdir.OnExtractOverwrite := ZipDirExtrOver;
- //Zipdir.Unattended := false;
- Zipdir.Unattended := true;
- //Zipdir.Password := 'PASS';
- end;
- {$ENDIF}
- {$IFDEF USE_ZIP}
- procedure TCakDir.UnLoad_ZIP_DLL;
- begin
- if assigned(Zipdir) then
- Zipdir.Free;
- Zipdir := nil;
- end;
- {$ENDIF}
-
- {$IFDEF USE_ACE2}
- procedure Ace2ErrorMsg(acode : integer ; amessage : string);
- begin
- if amessage <> '' then
- begin
- Ace2Msg := amessage;
- Ace2Code := acode;
- end;
- end;
-
- procedure Ace2Progress(filesize, totalsize : integer);
- begin
-
- end;
- function Ace2InfoProc(Info : pACEInfoCallbackProcStruc) : integer;
- var
- InfoStr : string;
- begin
- case Info^.Global.Code of
- ACE_CALLBACK_INFO_FILELISTCREATE:
- begin
- InfoStr := 'Creating file list';
- end;
- ACE_CALLBACK_INFO_FILELISTCREATEEND:
- InfoStr := 'Finished creating file list';
- ACE_CALLBACK_INFO_FILELISTADD:
- InfoStr := 'adding file to file list';
- else
- InfoStr := '';
- end;
- Result:=ACE_CALLBACK_RETURN_OK;
- end;
-
- function Ace2HandleErrorGlobal(Error : pACECallbackGlobalStruc) : integer;
- var
- ErrorStr : string;
- begin
- Result := ACE_CALLBACK_RETURN_OK;
-
- case Error^.Code of
- ACE_CALLBACK_ERROR_MEMORY:
- ErrorStr := 'not enough memory';
- ACE_CALLBACK_ERROR_UNCSPACE:
- ErrorStr := 'could not detect available space on network drive';
- else
- begin
- ErrorStr := 'unknown';
- Result := ACE_CALLBACK_RETURN_CANCEL;
- end;
- end;
- MessageDlg('Error: ' + Errorstr, mtError, [mbOK], 0);
- end;
-
- function Ace2HandleErrorArchive(Error : pACECallbackArchiveStruc) : integer;
- var
- ErrorStr : string;
- begin
- Result := ACE_CALLBACK_RETURN_OK;
- case Error^.Code of
- ACE_CALLBACK_ERROR_AV:
- ErrorStr := 'AV of archive %s invalid';
- ACE_CALLBACK_ERROR_OPENARCHIVEREAD:
- ErrorStr := 'could not open archive %s for reading';
- ACE_CALLBACK_ERROR_READARCHIVE:
- ErrorStr := 'error reading from archive %s';
- ACE_CALLBACK_ERROR_ARCHIVEBROKEN:
- ErrorStr := 'archive %s is broken';
- ACE_CALLBACK_ERROR_NOFILES:
- ErrorStr := 'no files specified';
- ACE_CALLBACK_ERROR_ISNOTANARCHIVE:
- ErrorStr := 'file is not an ACE archive';
- ACE_CALLBACK_ERROR_HIGHERVERSION:
- ErrorStr := 'this Dll version is not able to handle the archive';
- else
- begin
- ErrorStr := 'unknown';
- Result := ACE_CALLBACK_RETURN_CANCEL;
- end;
- end;
- MessageDlg(ErrorStr + Error^.ArchiveData^.ArchiveName, mtError, [mbOK], 0);
- end;
-
- function Ace2HandleErrorArchivedFile(Error : pACECallbackArchivedFileStruc) : integer;
- var
- ErrorStr : string;
- begin
- Result := ACE_CALLBACK_RETURN_OK;
- case Error^.Code of
- ACE_CALLBACK_ERROR_CREATIONNAMEINUSE:
- ErrorStr := 'could not extract %s: name used by directory';
- ACE_CALLBACK_ERROR_WRITE:
- ErrorStr := 'error writing %s';
- ACE_CALLBACK_ERROR_OPENWRITE:
- ErrorStr := 'error opening %s for writing';
- ACE_CALLBACK_ERROR_METHOD:
- ErrorStr := 'compression method not known to this Dll version';
- ACE_CALLBACK_ERROR_EXTRACTSPACE:
- ErrorStr := 'not enough space to extract %s';
- ACE_CALLBACK_ERROR_CREATION:
- ErrorStr := 'creation of %s failed (write-protection?)';
- else
- begin
- ErrorStr := 'unknown';
- Result := ACE_CALLBACK_RETURN_CANCEL;
- end;
- end;
- MessageDlg(ErrorStr + Error^.FileData^.SourceFileName, mtError, [mbOK], 0);
- end;
-
- function Ace2HandleErrorRealFile(Error : pACECallbackRealFileStruc) : integer;
- var
- ErrorStr : string;
- begin
- ErrorStr := 'unknown';
- Result := ACE_CALLBACK_RETURN_CANCEL;
- MessageDlg(ErrorStr + Error^.FileName, mtError, [mbOK], 0);
- end;
-
- function Ace2HandleErrorSpace(Error : pACECallbackSpaceStruc) : integer;
- var
- ErrorStr : string;
- begin
- ErrorStr := 'unknown';
- Result := ACE_CALLBACK_RETURN_CANCEL;
- MessageDlg(ErrorStr + Error^.Directory, mtError, [mbOK], 0);
- end;
-
- function Ace2HandleErrorSFXFile(Error : pACECallbackSFXFileStruc) : integer;
- var
- ErrorStr : string;
- begin
- ErrorStr := 'unknown';
- Result := ACE_CALLBACK_RETURN_CANCEL;
- MessageDlg(ErrorStr + Error^.SFXFileName, mtError, [mbOK], 0);
- end;
-
- function Ace2ErrorProc(Error : pACEErrorCallbackProcStruc) : integer;
- begin
- ShowMessage('ErrorProc');
- case Error^.StructureType of
- ACE_CALLBACK_TYPE_GLOBAL:
- Result:= Ace2HandleErrorGlobal(@Error^.Global);
- ACE_CALLBACK_TYPE_ARCHIVE:
- Result:= Ace2HandleErrorArchive(@Error^.Archive);
- ACE_CALLBACK_TYPE_ARCHIVEDFILE:
- Result:= Ace2HandleErrorArchivedFile(@Error^.ArchivedFile);
- ACE_CALLBACK_TYPE_REALFILE:
- Result:= Ace2HandleErrorRealFile(@Error^.RealFile);
- ACE_CALLBACK_TYPE_SPACE:
- Result:= Ace2HandleErrorSpace(@Error^.Space);
- ACE_CALLBACK_TYPE_SFXFILE:
- Result:= Ace2HandleErrorSFXFile(@Error^.SFXFile);
- else
- Result:=ACE_CALLBACK_RETURN_CANCEL;
- end;
-
- end;
-
- function Ace2HandleRequestGlobal(Request : pACECallbackGlobalStruc) : integer;
- begin
- MessageDlg('unknown request', mtError, [mbOK], 0);
- Result:=ACE_CALLBACK_RETURN_CANCEL;
- end;
-
- function Ace2HandleRequestArchive(Request : pACECallbackArchiveStruc) : integer;
- var
- RequestStr : string;
- begin
- case Request^.Code of
- ACE_CALLBACK_REQUEST_CHANGEVOLUME:
- RequestStr := 'ready to process next volume'
- else
- begin
- MessageDlg('unknown request', mtError, [mbOK], 0);
- Result:=ACE_CALLBACK_RETURN_CANCEL;
- Exit;
- end;
- end;
- if MessageDlg(RequestStr, mtConfirmation, [mbYes, mbNo], 0) = mrYes then
- Result:=1
- else
- Result:=0; // False
- end;
-
- function Ace2HandleRequestArchivedFile(Request : pACECallbackArchivedFileStruc) : integer;
- var
- RequestStr : string;
- begin
- case Request^.Code of
- ACE_CALLBACK_REQUEST_OVERWRITE:
- RequestStr := 'overwrite existing file ' + Request^.FileData^.SourceFileName;
-
- ACE_CALLBACK_REQUEST_PASSWORD:
- begin
- RequestStr := Request^.FileData^.SourceFileName +
- ' is encrypted, using "testpassword" as password';
- Request^.GlobalData^.DecryptPassword := 'testpassword';
- end
- else
- begin
- MessageDlg('unknown request', mtError, [mbOK], 0);
- Result:=ACE_CALLBACK_RETURN_CANCEL;
- Exit;
- end
- end;
- if MessageDlg(RequestStr, mtConfirmation, [mbYes, mbNo], 0) = mrYes then
- Result:=ACE_CALLBACK_RETURN_OK
- else
- Result:=ACE_CALLBACK_RETURN_NO; // False
- end;
-
- function Ace2HandleRequestRealFile(Request : pACECallbackRealFileStruc) : integer;
- begin
- MessageDlg('unknown request', mtError, [mbOK], 0);
- Result:=ACE_CALLBACK_RETURN_CANCEL;
- end;
-
- function Ace2RequestProc(Request : pACERequestCallbackProcStruc) : integer;
- begin
- case Request^.StructureType of
- ACE_CALLBACK_TYPE_GLOBAL:
- Result:=Ace2HandleRequestGlobal(@Request^.Global);
- ACE_CALLBACK_TYPE_ARCHIVE:
- Result:=Ace2HandleRequestArchive(@Request^.Archive);
- ACE_CALLBACK_TYPE_ARCHIVEDFILE:
- Result:=Ace2HandleRequestArchivedFile(@Request^.ArchivedFile);
- ACE_CALLBACK_TYPE_REALFILE:
- Result:=Ace2HandleRequestRealFile(@Request^.RealFile);
- else
- Result:=ACE_CALLBACK_RETURN_CANCEL;
- end;
- end;
-
- function Ace2HandleStateStartArchive(Archive : pACECallbackArchiveStruc) : integer;
- var
- ActionStr : string;
- begin
- case Archive^.Operation of
- ACE_CALLBACK_OPERATION_LIST:
- ActionStr := 'Listing ' + Archive^.ArchiveData^.ArchiveName;
- ACE_CALLBACK_OPERATION_TEST:
- ActionStr := 'Testing ' + Archive^.ArchiveData^.ArchiveName;
- ACE_CALLBACK_OPERATION_EXTRACT:
- ActionStr := 'Extracting ' + Archive^.ArchiveData^.ArchiveName;
- else
- ActionStr := 'unknown operation on ' + Archive^.ArchiveData^.ArchiveName;
- end;
-
- Result:=ACE_CALLBACK_RETURN_OK;
- end;
-
- function Ace2HandleStateStartFile(ArchivedFile : pACECallbackArchivedFileStruc) : integer;
- var
- ActionStr : string;
- begin
- case ArchivedFile^.Operation of
- ACE_CALLBACK_OPERATION_LIST:
- begin
- ActionStr := 'Found';
- end;
- ACE_CALLBACK_OPERATION_TEST:
- ActionStr := 'Testing';
- ACE_CALLBACK_OPERATION_ANALYZE:
- ActionStr := 'Analyzing';
- ACE_CALLBACK_OPERATION_EXTRACT:
- begin
- ActionStr := 'Extracting';
- Ace2ErrorMsg(0,ActionStr + ' ' + ArchivedFile^.FileData^.SourceFileName);
- //Form1.Gauge1.MaxValue:=ArchivedFile^.FileData^.Size;
- end;
- else
- ActionStr := 'unknown operation on';
- end;
-
- Result:=ACE_CALLBACK_RETURN_OK;
- end;
-
- procedure Ace2DisplayProgress(FileProcessedSize,
- FileSize,
- TotalProcessedSize,
- TotalSize : int64);
-
-
- var
- s : string;
- lKBWritten : int64;
- begin
- // Display/calculate progress for ACE extracting
- Application.ProcessMessages;
- lKBWritten := TotalProcessedSize;
-
- Ace2Progress(lKBwritten,TotalSize);
-
- Application.ProcessMessages;
- end; // AceDisplayProgress
-
- function Ace2StateProc(State : pACEStateCallbackProcStruc) : integer;
- begin
-
- if Stopprocess then
- begin
- Result:=ACE_CALLBACK_RETURN_CANCEL;
- Exit;
- end;
-
- case State^.StructureType of
- ACE_CALLBACK_TYPE_ARCHIVE:
- begin
- if (State^.Archive.Code = ACE_CALLBACK_STATE_STARTARCHIVE)
- and (State^.Archive.Operation = ACE_CALLBACK_OPERATION_EXTRACT)
- then
- begin
- // frmUnpack.lblCurrentFile.Caption:=State^.Archive.ArchiveData^.ArchiveName;
- // nixe
- end;
- end;
- ACE_CALLBACK_TYPE_ARCHIVEDFILE:
- begin
- case State^.ArchivedFile.Code of
- ACE_CALLBACK_STATE_STARTFILE:
- begin
- result:=Ace2HandleStateStartFile(@State^.ArchivedFile);
- exit;
- end;
- ACE_CALLBACK_STATE_ENDNOCRCCHECK:
- begin
- end;
- end;
- end;
- ACE_CALLBACK_TYPE_PROGRESS:
- begin
- if State^.Progress.Code = ACE_CALLBACK_STATE_PROGRESS then
- begin
- Ace2DisplayProgress(State^.Progress.ProgressData^.FileProcessedSize,
- State^.Progress.ProgressData^.FileSize,
- State^.Progress.ProgressData^.TotalProcessedSize,
- State^.Progress.ProgressData^.TotalSize);
-
- // nixe
- // ShowMessage('nixe processed: ' + IntToStr(State^.Progress.ProgressData^.FileProcessedSize) +
- // ' of ' + IntToStr(State^.Progress.ProgressData^.FileSize) +
- // ' bytes (' + IntToStr(State^.Progress.ProgressData^.TotalProcessedSize) +
- // ' of ' + IntToStr(State^.Progress.ProgressData^.TotalSize) + ' bytes)');
- end;
- end;
- ACE_CALLBACK_TYPE_CRCCHECK:
- begin
- if State^.CRCCheck.Code = ACE_CALLBACK_STATE_ENDCRCCHECK then
- begin
- if not State^.CRCCheck.CRCOk then
- MessageDlg('CRC-check error', mtError, [mbOK], 0);
- end;
- end;
- end;
-
- Result:=ACE_CALLBACK_RETURN_OK;
- end;
- {$ENDIF}
-
- {$IFDEF USE_ACE2}
- function TCakdir.CallAceInitDll : integer;
- var
- DllData : tACEInitDllStruc;
- zTempDir : array[0..255] of char;
- begin
- FillChar(DllData, SizeOf(DllData), 0);
- DllData.GlobalData.MaxArchiveTestBytes := $1ffFF;
- DllData.GlobalData.MaxFileBufSize := $2ffFF;
- DllData.GlobalData.Comment.BufSize := SizeOf(CommentBuf)-1;
- DllData.GlobalData.Comment.Buf := @CommentBuf;
-
- GetTempPath(255, @zTempDir);
- DllData.GlobalData.TempDir := @zTempDir;
-
- DllData.GlobalData.InfoCallbackProc := @Ace2InfoProc;
- DllData.GlobalData.ErrorCallbackProc := @Ace2ErrorProc;
- DllData.GlobalData.RequestCallbackProc := @Ace2RequestProc;
- DllData.GlobalData.StateCallbackProc := @Ace2StateProc;
-
- Result:=ACEInitDll(@DllData);
- end;
- {$ENDIF}
-
- {$IFDEF USE_ACE}
- procedure TCakDir.Load_ACE_DLL;
- var i : integer;
- begin
- if not assigned(Acedir) then
- Acedir := TdAce.Create(self);
- Acedir.Path2UnAceDll := Extractfilepath(ParamStr(0));
- Acedir.OnList := AceDirList;
- Acedir.OnError := AceDirError;
- Acedir.OnExtracting := AceDirExtracting;
- {$IFDEF USE_ACE2}
- if LoadAceDll('') then
- begin
- i:= CallAceInitDll;
- if i <> 0 then
- Ace2ErrorMsg(0,'Unable to initialize unace2.dll. Error code: '+IntToStr(i));
- end else
- Ace2ErrorMsg(0,'Unable to load unace2.dll!');
- {$ENDIF}
- end;
- {$ENDIF}
-
- {$IFDEF USE_ACE}
- procedure TCakDir.UnLoad_ACE_DLL;
- begin
- if not assigned(Acedir) then exit;
- Acedir.OnList := nil;
- Acedir.OnError := nil;
- Acedir.OnExtracting := nil;
- {$IFDEF USE_ACE2}
- UnLoadAceDll
- {$ENDIF}
- //Acedir.Free; //Crash here...
- //Acedir := nil;
- end;
- {$ENDIF}
-
- {$IFDEF USE_RS}
- procedure TCakDir.Load_RS_DLL;
- begin
- if not assigned(Rsdir) then
- RsDir := TResource.Create(Self);
- RsDir.OnaddLog := RsDirAddLog;
- RsDir.OnCentralDirChange := RsDirCDChange;
- end;
- {$ENDIF}
-
- procedure TCakDir.Load_CAB_DLL;
- begin
- if not assigned(CabFH) then
- CabFH := TStreamCabinetFileHandler.Create(Self);
- if not assigned(CabWDir) then
- begin
- CabWDir := TCabinetWriter.Create(Self);
- CabWDir.FileHandler := CabFH;
- CabWDir.OnFilePlacedEvent := CabWFilePlaced;
- end;
- if not assigned(CabRDir) then
- begin
- CabRDir := TCabinetReader.Create(Self);
- CabRDir.FileHandler := CabFH;
- CabRDir.OnCloseCopiedFile := CabRDirCloseCopied;
- CabRDir.OnCopyFile := CabRCopyFile;
- CabRDir.OnNextCabinet := CabRNextCab;
- end;
- CabMode := _CFList;
- end;
- procedure TCakDir.UNLoad_CAB_DLL;
- begin
- if assigned(CabWDir) then
- begin
- CabWDir.Free;
- CabWDir := nil
- end;
- if assigned(CabRDir) then
- begin
- CabRDir.Free;
- CabRDir := nil
- end;
- if assigned(CabFH) then
- begin
- CabFH.Free;
- CabFH := nil
- end;
- end;
-
- procedure TCakDir.Load_EXT_DLL;
- begin
- if not assigned(CakExt) then
- CakExt := TCakExt.Create(self);
- CakExt.Logfile := CakExtLogfile;
- end;
-
- procedure TCakDir.UNLoad_EXT_DLL;
- begin
- if assigned(CakExt) then
- begin
- CakExt.free;
- CakExt := nil;
- end;
- end;
-
- procedure TCakdir.SetScriptPath(path : string);
- begin
- LOAD_EXT_DLL;
- CakExt.ScriptDirectory := path;
- cakext.RePollScriptDirectory;
- TreatasExt := Cakext.Supportformats;
- end;
-
- {$IFDEF USE_RS}
- procedure TCakDir.UnLoad_RS_DLL;
- begin
- if not assigned(Rsdir) then exit;
- Rsdir.OnaddLog := nil;
- Rsdir.Free;
- Rsdir := nil;
- end;
- {$ENDIF}
-
- {$IFDEF USE_WINEXT}
- procedure TCakDir.GetFileType(filename : string; var info1,info2, info3 : string);
- var i : integer;
- aExinfo : ExInfo;
- begin
- info1 := '';
- info2 := '';
- info3 := '';
- i := -1;
- if Winex32.DLLLoaded then
- i := WinExGetInfo(PCHAR(filename),
- BUFFSIZE_6000,
- aExinfo,
- 0);
- if i = 0 then
- begin
- info1 := aExinfo.szFileEx;
- info2 := aExinfo.szExInfo1;
- info3 := aExinfo.szExInfo2;
- end;
- end;
- {$ENDIF}
-
- {$IFDEF USE_WINEXT}
- function TCakDir.GetARCtype2(archivename : string) : supporttype;
- var i : integer;
- k : string;
- aExinfo : ExInfo;
- begin
- Result := _WIT;
- if Winex32.DLLLoaded then
- begin
- i := WinExGetInfo(PCHAR(Archivename),
- BUFFSIZE_6000,
- aExinfo,
- 0);
- if i = 0 then
- begin
- k := aExinfo.szExInfo1;
- k := trim(k);
- k := Uppercase(Copy(k,0,3));
- if k = WinEXT_ZIP then result := _ZIP else
- if k = WinEXT_CAB then result := _CAB else
- if k = WinEXT_LHA then result := _LHA else
- if k = WinEXT_ARJ then result := _ARJ else
- if k = WinEXT_TAR then result := _TAR else
- if k = WinEXT_BZ2 then result := _BZ2;
- end;
- end;
- if Result = _WIT then
- Result := GetArctype1(Archivename);
- end;
- {$ENDIF}
-
- function TCakDir.GetARCtype1(archivename : string) : supporttype;
- var ext : string;
- begin
- ext := Uppercase(Extractfileext(archivename)) + ' ';
- if pos(ext,Uppercase(AsZip)+ ' ') > 0 then Result := _Zip else
- if pos(ext,Uppercase(AsAks)+ ' ') > 0 then Result := _Aks else
- if pos(ext,Uppercase(AsCab)+ ' ') > 0 then Result := _Cab else
- if pos(ext,Uppercase(AsRar)+ ' ') > 0 then Result := _Rar else
- if pos(ext,Uppercase(AsLha)+ ' ') > 0 then Result := _Lha else
- if pos(ext,Uppercase(AsArj)+ ' ') > 0 then Result := _Arj else
- if pos(ext,Uppercase(AsAce)+ ' ') > 0 then Result := _Ace else
- if pos(ext,Uppercase(AsTar)+ ' ') > 0 then Result := _Tar else
- if pos(ext,Uppercase(AsTgz)+ ' ') > 0 then Result := _Tgz else
- if pos(ext,Uppercase(AsBz2)+ ' ') > 0 then Result := _Bz2 else
- if pos(ext,Uppercase(AsBel)+ ' ') > 0 then Result := _Bel else
- if pos(ext,Uppercase(AsGca)+ ' ') > 0 then Result := _Gca else
- if pos(ext,Uppercase(AsBza)+ ' ') > 0 then Result := _Bza else
- if pos(ext,Uppercase(AsCzip)+ ' ') > 0 then Result := _Czip else
- if pos(ext,Uppercase(AsRs)+ ' ') > 0 then Result := _Rs else
- if pos(ext,Uppercase(AsYz1)+ ' ') > 0 then Result := _Yz1 else
- if pos(ext,Uppercase(AsUue)+ ' ') > 0 then Result := _Uue else
- if pos(ext,Uppercase(AsXxe)+ ' ') > 0 then Result := _Xxe else
- if pos(ext,Uppercase(AsB64)+ ' ') > 0 then Result := _B64 else
- if pos(ext,Uppercase(AsPak)+ ' ') > 0 then Result := _Pak else
- Result := _WIT;
-
- if Result = _WIT then
- if pos(ext,Uppercase(TreatAsExt)) > 0 then Result := _EXT;
- end;
-
- function TCakDir.GetARCtype(archivename : string) : supporttype;
- begin
- {$IFDEF USE_WINEXT}
- Result := GetARCtype2(Archivename);
- {$ELSE}
- Result := GetARCtype1(Archivename);
- {$ENDIF}
- end;
-
- function TCakDir.AskOverwrite(forfile : string) : boolean;
- var i : integer;
- DoOverwrite : boolean;
- overwrite,applytoall : boolean;
- begin
- DoOverwrite := false;
- if ExtractOptions.extr_OverWrite then DoOverwrite := true else
- if overwriteall = 1 then DoOverwrite := true else
- if overwriteall = 2 then DoOverwrite := false else
- if assigned(FOnOver) then
- begin
- FOnOver(nil,ForFile,overwrite,applytoall);
- Dooverwrite := overwrite;
- if applytoall then
- if overwrite then
- overwriteall := 1 else
- overwriteall := 2;
- end else
- begin
- i := MessageDlg('Overite ' + Forfile + '?', mtWarning, [mbYes, mbNo, mbYesToAll, mbNoToAll], 0);
- Case i of
- MrYes : DoOverwrite := True;
- MrNo : DoOverwrite := False;
- MrYestoAll : Begin DoOverwrite := True; overwriteall := 1; end;
- MrNotoAll : Begin DoOverwrite := False; overwriteall := 2; end;
- end;
- end;
- Result := DoOverwrite;
- end;
-
- function TCakDir.Compare(Item1, Item2: Contenttype; FSortforward : boolean; atype: Sortbytype): integer;
- var
- Resu: integer;
- begin
- try
- resu := 0;
- case atype of
- (* Filename Column *)
- _FName:
- Resu := CompareText(item1._Filename, Item2._Filename);
- _FType :
- Resu := CompareText(item1._Filetype , Item2._Filetype);
- _FDefPath :
- Resu := CompareText(item1._FileDefPath, item2._FileDefPath);
- _FArchive :
- CompareText(item1._FileArchive, Item2._FileArchive);
- _FSize :
- Resu := (Item1._FileSize - Item2._FileSize);
- _FPSize:
- Resu := (Item1._FilePackedSize - Item2._FilePackedSize);
- _FTime :
- Resu := Round(item1._FileTime - item2._FileTime);
- _FCRC :
- CompareText(item1._FileCRC, Item2._FileCRC);
- _FRatio:
- Resu := (Item1._FileRatio - Item2._FileRatio);
- end;
- except
- Resu := 0;
- end;
- if resu = 0 then
- Resu := CompareText(item1._Filename, Item2._Filename);
- if resu = 0 then
- Resu := CompareText(item1._FileDefPath, Item2._FileDefPath);
- if FSortforward then Result := resu
- else
- Result := -Resu;
- end;
-
- procedure TCakDir.QuickSort(var Sortarray: array of Contenttype; size: integer;
- FSortforward : boolean; atype: Sortbytype);
- var
- array1, array2, array3: array of Contenttype;
- middle: Contenttype;
- pivot, size1, size2, size3, i, j: integer;
- begin
- if size <= 1 then exit;
- pivot := size div 2;
- middle := Sortarray[pivot];
- Setlength(array1, size);
- Setlength(array2, size);
- Setlength(array3, size);
-
- size1 := 0;
- size2 := 0;
- size3 := 0;
- for i := 0 to size - 1 do
- if pivot <> i then
- begin
- j := Compare(Sortarray[i], middle, FSortforward, atype);
- if j > 0 then
- begin
- array1[size1] := sortarray[i];
- size1 := size1 + 1;
- end;
- if j < 0 then
- begin
- array2[size2] := sortarray[i];
- size2 := size2 + 1;
- end;
- if j = 0 then
- begin
- array3[size3] := sortarray[i];
- size3 := size3 + 1;
- end;
- end;
-
-
- if (size1 > 1) then
- QuickSort(array1, size1, FSortforward, atype);
- if (size2 > 1) then
- QuickSort(array2, size2, FSortforward, atype);
-
- Setlength(array1, size1);
- Setlength(array2, size2);
- Setlength(array3, size3);
-
- sortarray[size1] := middle;
-
- if size1 > 0 then
- for i := 0 to size1 - 1 do
- sortarray[i] := array1[i];
-
- if size3 > 0 then
- for i := 0 to size3 - 1 do
- sortarray[size1 + i + 1] := array3[i];
-
- if size2 > 0 then
- for i := 0 to size2 - 1 do
- Sortarray[size1 + size3 + i + 1] := array2[i];
- end;
-
-
-
- procedure TCakDir.Append_Archive_List(filename : string; appendto : integer);
- var i : integer;
- begin
- Inc(Total_Archive);
- SetLength(Archive_List,Total_Archive+1);
- for i := Total_Archive-1 downto appendto do
- Archive_List[i] := Archive_List[i-1];
- Archive_List[appendto]._ArcName := filename;
- Archive_List[appendto]._ArcType := GetARCType(filename);
- end;
-
- procedure TCakDir.Sort_Archive_List(accending : boolean; atype: Sortbytype);
- begin
- QuickSort(Archive_Contents,Total_Contents,NOT accending,atype);
- end;
-
- procedure TCakDir.Set_Archive_List(filename : string);
- begin
- Clear_Archive_List;
- Inc(Total_Archive);
- SetLength(Archive_List,Total_Archive);
- Archive_List[Total_Archive-1]._Arcname := filename;
- if fileexists(filename) then
- Archive_List[Total_Archive-1]._ArcType := GetARCType(filename) else
- Archive_List[Total_Archive-1]._ArcType := GetARCType1(filename);
- end;
-
- function TCakDir.Add_Archive_List(filename : string) : integer;
- begin
- Inc(Total_Archive);
- SetLength(Archive_List,Total_Archive);
- Archive_List[Total_Archive-1]._Arcname := filename;
- Archive_List[Total_Archive-1]._ArcType := GetARCType(filename);
- result := Total_Archive-1;
- end;
-
- procedure TCakDir.Clear_Archive_List;
- begin
- Total_Archive := 0;
- SetLength(Archive_List,Total_Archive+1);
- Total_Contents := 0;
- fullcontentcount := 0;
- SetLength(Full_Contents,Total_Contents+1);
- SetLength(Archive_Contents,Total_Contents+1);
- Directorylist.clear;
- end;
-
- function TCakDir.found(filename : string) : boolean;
- var i : integer;
- aMask : TMask;
- begin
- result := false;
- aMask := TMask.Create(filename);
- for i := 0 to Total_Contents -1 do
- if aMask.Matches(Archive_Contents[i]._Filename) then
- result := true;
- aMask.free;
- end;
- function TCakDir.Get_Archive_Code(filearchive, filename : string) : integer;
- var i : integer;
- begin
- result := -1;
- for i := 0 to Total_Contents -1 do
- if uppercase(Archive_Contents[i]._Filedefpath) + uppercase(Archive_Contents[i]._Filename) = uppercase(filename) then
- if uppercase(Archive_Contents[i]._FileArchive) = uppercase(filearchive) then
- result := i;
- end;
- function TCakdir.Get_Top_Selected : string;
- var i,j : integer;
- begin
- j := total_contents+1;
- for i := Total_Contents -1 downto 0 do
- if Archive_contents[i]._selected then
- j := i;
- if j >= total_contents +1 then
- result := '' else
- result := archive_contents[j]._filedefpath + archive_contents[j]._filename;
- end;
-
- function TCakDir.GrabMydocuPath : string;
- var Path: array [0..260] of char;
- ItemIDList : PItemIDList;
- begin
- SHGetSpecialFolderLocation(Application.handle,CSIDL_PERSONAL,ItemIDList);
- SHGetPathFromIDList(ITEMIDLIST,path);
- result := Appendslash(path);
- end;
-
- function TCakDir.GrabWindowPath : string;
- var Path: array [0..260] of char;
- begin
- GetWindowsDirectory(Path, Sizeof(Path));
- result := Appendslash(path);
- end;
- function TCakDir.GrabSystemPath : string;
- var Path: array [0..260] of char;
- begin
- GetSystemDirectory(Path, Sizeof(Path));
- result := Appendslash(path);
- end;
- function TCakDir.GrabTempPath : string;
- var Path: array [0..260] of char;
- begin
- GetTempPath(Sizeof(Path), Path);;
- result := Appendslash(path);
- end;
- function TCakDir.GrabDesktopPath : string;
- begin
- Result := SpecialDirectory(CSIDL_Desktopdirectory);
- end;
-
- function TCakDir.GrabProgramPath : string;
- begin
- Result := AppendSlash(Extractfilepath(Paramstr(0)));
- end;
-
-
- function TCakDir.GrabCurrentPath : string;
- var Path: array [0..260] of char;
- begin
- GetCurrentDirectory(Sizeof(Path), Path);
- result := Appendslash(path);
- end;
-
-
- procedure TCakDir.MakeDirectory(dirname: string);
- var
- i: integer;
- a, temp: string;
- begin
- a := dirname;
- temp := '';
- for i := 1 to length(a) + 1 do
- begin
- temp := Copy(a, 0, i);
- if (a[i] = '\') or (i = length(a) + 1) then
- if not directoryexists(temp) then
- CreateDirectory(PChar(temp), nil);
- end;
- end;
-
- function TCakDir.CalcFolderSize(const aRootPath: string): Int64;
-
- procedure Traverse(const aFolder: string);
- var
- Data: TWin32FindData;
- FileHandle: THandle;
- begin
- FileHandle := FindFirstFile(PCHAR(aFolder+'*'), Data);
- if FileHandle <> INVALID_HANDLE_VALUE then
- try
- repeat
- if (Data.dwFileAttributes AND FILE_ATTRIBUTE_DIRECTORY > 0)
- and (Data.cFileName[0] <> '.') then
- Traverse(aFolder+Data.cFilename+'\')
- else Inc(Result, (Data.nFileSizeHigh * MAXDWORD) +
- Data.nFileSizeLow);
- until not FindNextFile(FileHandle, Data);
- finally
- Windows.FindClose(FileHandle);
- end;
- end;
- begin
- Result := 0;
- Traverse(aRootPath);
- end;
-
- {$IFDEF USE_ZIP}
- procedure TCakDir.Zipdirrename(SourceName, DestName: string);
- var
- ZipRenameList: TList;
- RenRec: pZipRenameRec;
- begin
- ZipRenameList := TList.Create();
- New(RenRec);
- RenRec^.Source := SourceName;
- RenRec^.Dest := DestName;
- RenRec^.DateTime := 0;
-
- ZipRenameList.Add(RenRec);
-
- Zipdir.Rename(ZipRenameList, 0);
- Dispose(RenRec);
- ZipRenameList.Free();
-
- UNLoad_ZIP_DLL;
- Load_ZIP_DLL;
- List_archive(0,Total_Archive -1 );
- end;
- {$ENDIF}
-
- {$IFDEF USE_ZIP}
- procedure TCakDir.Zipdirrenamedir(SourceName, DestName: string);
- var
- j,k : string;
- i : integer;
- begin
- for i := 0 to total_contents -1 do
- if (Uppercase(Archive_contents[i]._Filedefpath) = Uppercase(Appendslash(SourceName))) then
- begin
- j := Archive_contents[i]._filedefpath + Archive_contents[i]._filename;
- k := Appendslash(DestName) + Archive_contents[i]._filename;
- zipdirrename(j,k);
- end;
- end;
- {$ENDIF}
- procedure TCakDir.DelValInReg(RKey: HKey; KeyPath: string; Key : string);
- begin
- with TRegistry.Create do
- try
- RootKey := RKey;
- OpenKey(KeyPath, True);
- if valueexists(key) then
- DeleteValue(Key);
- finally
- Free;
- end;
- end;
-
- procedure TCakDir.DelKeyInReg(RKey: HKey; KeyPath: string);
- var valstrings,subkeystrings : tstrings;
- i : integer;
- begin
- if keypath = '' then exit;
- valstrings := RegListVal(Rkey,Keypath);
- subkeystrings := RegListsubKey(RKey,Keypath);
- for i := 0 to subkeystrings.count -1 do
- DelKeyInReg(RKey,Keypath + subkeystrings.strings[i]);
- for i := 0 to valstrings.count -1 do
- DelValInReg(RKey,Keypath,valstrings.strings[i]);
- subkeystrings.free;
- valstrings.free;
- RegDeleteKey(Rkey, PCHAR(keypath));
- end;
-
-
- procedure TCakDir.SetValInReg(RKey: HKey; KeyPath: string;
- ValName: string; NewVal: string);
- begin
- with TRegistry.Create do
- try
- RootKey := RKey;
- OpenKey(KeyPath, True);
- WriteString(ValName, NewVal);
- finally
- Free;
- end;
- end;
-
- function TCakDir.GetvalInReg(RKey : HKey; KeyPath : string;
- Valname : string) : string;
- begin
- with TRegistry.Create do
- try
- RootKey := RKey;
- OpenKey(KeyPath, True);
- result := Readstring(ValName);
- finally
- Free;
- end;
- end;
-
- function TCakDir.GetvalInIni(filename : string; section : string; key : string; default : string) : string;
- var Ini : TInifile;
- begin
- Ini := TIniFile.Create(filename);
- try
- with Ini do
- result := ReadString(section,key,'');
- finally
- Ini.Free;
- end;
- if result = '' then result := default;
- end;
-
-
- procedure TCakDir.SetvalInIni(filename : string; section : string; key, value : string);
- var Ini : TInifile;
- begin
- Ini := TIniFile.Create(filename);
- try
- with Ini do
- WriteString(section,key,value);
- finally
- Ini.Free;
- end;
- end;
-
- procedure TCakDir.PlainDialog;
- begin
- aform := TForm.Create(nil);
- aCheckbox := TCheckbox.Create(aform);
- aCheckbox.Parent := aform;
- aLabel := TStatictext.Create(aform);
- aLabel.Parent := aform;
-
- aLabel.AutoSize := False;
- aCheckbox.Checked := False;
-
- aform.width := 286;
- aform.height := 240;
- aform.Position := poDesktopCenter;
- aform.BorderStyle := bsDialog;
-
- ALabel.Left := 10;
- ALabel.Top := 30;
- ALabel.width := aform.width - (alabel.Left *2);
- ALabel.Alignment := taCenter;
- ALabel.Height := 60;
-
- aCheckbox.width := 180;
-
- aCheckbox.checked := true;
- aCheckbox.Caption := MSG_SHOWAGAIN;
-
- aCheckbox.Top := 120;
- aCheckbox.Left := (aform.width -aCheckbox.width) div 2;
- end;
- procedure TCakDir.FreePlainDialog;
- begin
- aCheckbox.free;
- aLabel.free;
- aform.free;
- end;
-
- function TCakDir.YesNoShowAgainDialog(dcaption,msg : string; var yesno : boolean) : boolean;
- var yButton,nButton : TButton;
- begin
- result := true;
- PlainDialog;
- yButton := TButton.Create(aform);
- yButton.Parent := aform;
- yButton.ModalResult := 1;
- yButton.Default := true;
- nButton := TButton.Create(aform);
- nButton.Parent := aform;
- nButton.ModalResult := 2;
- nButton.Cancel := true;
- try
- aform.Caption := dcaption;
- aLabel.Caption := Msg;
- yButton.Top := 160;
- nButton.Top := 160;
- yButton.width := 75;
- yButton.Caption := 'Yes';
- nButton.width := 75;
- nButton.Caption := 'No';
- yButton.Left := (aform.width -yButton.width) div 2 - 75;
- nButton.Left := (aform.width -nButton.width) div 2 + 75;
-
- aform.Showmodal;
-
- if aform.ModalResult = 1 then
- YesNo := true else
- YesNo := false;
- if not aCheckbox.Checked then
- result := false;
- finally
- ybutton.free;
- nbutton.free;
- freePlaindialog;
- end;
-
- end;
- function TCakDir.ShowAgainDialog(dcaption, msg : string) : boolean;
- var aButton : TButton;
- begin
- result := true;
- PlainDialog;
- aButton := TButton.Create(aform);
- aButton.Parent := aform;
- aButton.ModalResult := 1;
- aButton.Default := true;
-
- try
- aform.Caption := dcaption;
- aLabel.Caption := Msg;
- aButton.Top := 160;
- aButton.Left := (aform.width -aButton.width) div 2;
-
- aButton.width := 75;
- aButton.Caption := 'Close';
- aform.Showmodal;
-
- if not aCheckbox.Checked then
- result := false;
- finally
-
- abutton.free;
- freePlaindialog;
- end;
- end;
-
- procedure TCakDir.RegAskShowAgainDialog(dcaption, Msg : string; Path, key : string);
- begin
-
- if GetValInReg(HKEY_CLASSES_ROOT,Path,key) <> 'FALSE' then
- if ShowAgainDialog(dcaption,msg) then
- SetValinReg(HKEY_CLASSES_ROOT,Path,key,'TRUE') else
- SetValinReg(HKEY_CLASSES_ROOT,Path,key,'FALSE')
- end;
-
- procedure TCakDir.IniAskShowAgainDialog(dcaption, Msg : string; Filename, section, key : string);
- begin
- if GetvalInIni(filename,section,key,'TRUE') <> 'FALSE' then
- if ShowAgainDialog(dcaption,msg) then
- SetvalInIni(filename,section,key,'TRUE') else
- SetvalInIni(filename,section,key,'FALSE')
- end;
-
- procedure TCakDir.RegYesNoAskShowAgainDialog(dcaption, Msg : string; Path, section, key : string;var yesno : boolean);
- begin
- if GetValInReg(HKEY_CLASSES_ROOT,Path,key) <> 'FALSE' then
- if YesNoShowAgainDialog(dcaption,msg,yesno) then
- SetValinReg(HKEY_CLASSES_ROOT,Path,key,'TRUE') else
- SetValinReg(HKEY_CLASSES_ROOT,Path,key,'FALSE')
- end;
- procedure TCakDir.IniYesNoAskShowAgainDialog(dcaption, Msg : string; Filename, Product, section, key : string;var yesno : boolean);
- begin
- if GetvalInIni(filename,Product,key,'TRUE') <> 'FALSE' then
- if YesNoShowAgainDialog(dcaption,msg,YesNo) then
- SetvalInIni(filename,section,key,'TRUE') else
- SetvalInIni(filename,section,key,'FALSE')
-
- end;
-
- procedure TCakDir.refreshicon;
- begin
- Shlobj.SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_FLUSH, nil, nil );
- reiniticons;
- end;
-
- function TCakDir.GetAssociatedprogram(ext : string) : string;
- begin
- Ext := LowerCase(Ext);
- result := Getvalinreg(HKEY_CLASSES_ROOT,'.' + ext,'');
- end;
-
- procedure TCakDir.UNAssociateProgram(ext : string);
- begin
-
- Ext := LowerCase(Ext);
- delkeyinreg(HKEY_CLASSES_ROOT,
- '.' + ext); { extension we want to undefine }
- delkeyinreg(HKEY_CLASSES_ROOT,
- leadchar + ext + '\DefaultIcon');
- delkeyinreg(HKEY_CLASSES_ROOT,
- leadchar + ext + '\shell\open\command');
- delkeyinreg(HKEY_CLASSES_ROOT,
- leadchar + ext);
- delkeyinreg(HKEY_CLASSES_ROOT,
- leadchar + ext);
- end;
- procedure TCakDir.AssociateProgram(ext,path,icon : string);
- begin
- { ALL extensions must be in lowercase to avoid trouble! }
- Ext := LowerCase(Ext);
- if FileExists(path) then
- begin
- SetValInReg(HKEY_CLASSES_ROOT,
- '.' + ext, { extension we want to define }
- '', { specify the default data item }
- leadchar + ext); { This is the value of the default data item -
- this referances our new type to be defined }
- SetValInReg(HKEY_CLASSES_ROOT,
- leadchar + ext, { this is the type we want to define }
- '', { specify the default data item }
- ext + ' Archive'); { This is the value of the default data item -
- this is the English description of the file type }
- ext := UPPERCASE(ext);
- SetValInReg(HKEY_CLASSES_ROOT,
- leadchar + ext + '\DefaultIcon', { Create a file...DefaultIcon.}
- '', { Specify the default data item.}
- icon+ ',0'); { Executable where icon is in and it's Sequence number.}
-
- SetValInReg(HKEY_CLASSES_ROOT,
- leadchar + ext + '\shell\open\command', { create a file...open key }
- '', { specify the default data item }
- path + ' "%1"'); { command line to open file with }
- end;
-
- end;
-
- function TCakDir.ArcOpenSupport : string;
- var k,l : string;
- begin
- k := '(^8^)';
- l := GrabProgramPath;
- {$IFDEF USE_ZIP}
- if fileexists(l + UNZIPDLL) then
- k := k + ',' + GetarcStringFull(_ZIP);
- {$ENDIF}
- {$IFDEF USE_ACE}
- if fileexists(l + UNACEDLL) then
- k := k + ',' + GetarcStringFull(_ACE);
- {$ENDIF}
- {$IFDEF USE_ARC}
- if fileexists(l + UNRARDLL) then
- k := k + ',' + GetarcStringFull(_RAR);
- if fileexists(l + LHADLL) then
- k := k + ',' + GetarcStringFull(_LHA);
- if fileexists(l + BZ2DLL) then
- k := k + ',' + GetarcStringFull(_BZ2);
- if fileexists(l + BZADLL) and fileexists(l+BZ2DLL) then
- k := k + ',' + GetarcStringFull(_BZA);
- if fileexists(l + UNARJDLL) then
- k := k + ',' + GetarcStringFull(_ARJ);
- if fileexists(l + TARDLL) then
- k := k + ',' + GetarcStringFull(_TAR) + ',' + GetarcStringFull(_TGZ);
- if fileexists(l + YZ1DLL) then
- k := k + ',' + GetarcStringFull(_YZ1);
- if fileexists(l + BELDLL) then
- k := k + ',' + GetarcStringFull(_BEL);
- if fileexists(l + GCADLL) then
- k := k + ',' + GetarcStringFull(_GCA);
- {$ENDIF}
- {$IFDEF USE_CZIP}
- k := k + ',' + GetarcStringFull(_CZIP);
- {$ENDIF}
- {$IFDEF USE_RS}
- k := k + ',' + GetarcStringFull(_RS);
- {$ENDIF}
- {$IFDEF USE_INDY}
- k := k + ',' + GetarcStringFull(_UUE);
- k := k + ',' + GetarcStringFull(_XXE);
- k := k + ',' + GetarcStringFull(_B64);
- {$ENDIF}
- k := k + ',' + GetarcStringFull(_CAB);
- k := k + ',' + GetarcStringFull(_PAK);
- k := k + ',' + GetarcStringFull(_AKS);
- result := k;
- end;
-
- function TCakDir.ArcAddSupport : string;
- var k,l : string;
- begin
- k := '(^8^)';
- l := GrabProgramPath;
- {$IFDEF USE_RS}
- k := k + ',' + GetarcStringFull(_RS);
- {$ENDIF}
- {$IFDEF USE_ZIP}
- if fileexists(l + ZIPDLL) then
- k := k + ',' + GetarcStringFull(_ZIP);
- {$ENDIF}
- {$IFDEF USE_ARC}
- if fileexists(l + LHADLL) then
- k := k + ',' + GetarcStringFull(_LHA);
- if fileexists(l + BZ2DLL) then
- k := k + ',' + GetarcStringFull(_BZ2);
- if fileexists(l + BZADLL) and fileexists(l+BZ2DLL) then
- k := k + ',' + GetarcStringFull(_BZA);
- if fileexists(l + TARDLL) then
- k := k + ',' + GetarcStringFull(_TAR) + ',' + GetarcStringFull(_TGZ);
- if fileexists(l + YZ1DLL) then
- k := k + ',' + GetarcStringFull(_YZ1);
- {$ENDIF}
- //{$IFDEF USE_INDY}
- //k := k + ',UU,UUE,XXE,B64';
- //{$ENDIF}
- k := k + ',' + GetarcStringFull(_CAB);
- result := k;
- end;
-
- function TCakDir.GetarcString(atype : supporttype) : string;
- var astrings : tstrings;
- begin
- aStrings := TStringList.create;
- astrings.CommaText := GetArcStringFull(atype);
- if astrings.count > 0 then
- result := astrings.strings[0];
- aStrings.free;
- end;
- function TCakDir.GetarcStringFull(atype : supporttype) : string;
- function LoadTreatAs(TreatAs : string) : string;
- var i : integer;
- k : string;
- begin
- k := treatas;
- i := pos(' ',k);
- while i <> 0 do
- begin
- k := copy(k,0,i-1) + copy(k,i+1,length(k)-1);
- i := pos(' ',k);
- end;
-
- i := pos('.',k);
- if i <> 0 then
- k := Copy(k,i+1,length(k) - i);
-
- i := pos('.',k);
- While i <> 0 do
- begin
- k := copy(k,0,i-1) + ',' + copy(k,i+1,length(k)-1);
- i := pos('.',k);
- end;
-
- result := k;
- end;
- begin
- case atype of
- _ZIP : result := Loadtreatas(TreatAsZip);
- _Rar : result := Loadtreatas(TreatAsRar);
- _Cab : result := Loadtreatas(TreatAsCab);
- _Arj : result := Loadtreatas(TreatAsArj);
- _Lha : result := Loadtreatas(TreatAsLha);
- _Tar : result := Loadtreatas(TreatAsTar);
- _Tgz : result := Loadtreatas(TreatAsTgz);
- _Ace : result := Loadtreatas(TreatAsAce);
- _BZ2 : result := Loadtreatas(TreatAsBz2);
- _Bel : result := Loadtreatas(TreatAsBel);
- _Gca : result := Loadtreatas(TreatAsGca);
- _Bza : result := Loadtreatas(TreatAsBza);
- _RS : result := Loadtreatas(TreatAsRs);
- _CZIP: result := Loadtreatas(TreatAsCZip);
- _YZ1 : result := Loadtreatas(TreatAsYz1);
- _UUE : result := Loadtreatas(TreatAsUue);
- _XXE : result := Loadtreatas(TreatAsXxe);
- _B64 : result := Loadtreatas(TreatAsB64);
- _PAK : result := Loadtreatas(TreatAsPak);
- _AKS : result := Loadtreatas(TreatAsAks);
- _EXT : result := Loadtreatas(TreatAsExt);
- _WIT : result := '?HUH?';
- end;
- end;
- function TCakDir.GetarcStringFilter(atype : supporttype) : string;
- var astrings : tstrings;
- i : integer;
- k : string;
- begin
- aStrings := TStringList.create;
- astrings.CommaText := GetArcStringFull(atype);
- k := '';
- for i := 0 to astrings.count -1 do
- if k = '' then
- k := '*.' + astrings.strings[i] else
- k := k + ';*.'+ astrings.strings[i];
- aStrings.free;
- result := k;
- end;
- procedure TCakDir.runwww(wwwpath : string);
- begin
- shellexecute(application.handle,'open',pchar(
- wwwpath),'',
- '',SW_SHOWNORMAL);
- end;
- procedure TCakDir.run(programpath,Programparam : string);
- var k : string;
- begin
- if uppercase(extractfileext(programpath)) = '.INF' then
- begin
- execinf(programpath,k);
- exit;
- end;
- if uppercase(extractfileext(programpath)) = '.REG' then
- begin
- execreg(programpath);
- exit;
- end;
-
- shellexecute(application.handle,'open',pchar(
- extractfilename(programpath)),pchar(programparam),
- pchar(extractfilepath(programpath)),SW_SHOWNORMAL);
- end;
-
- procedure TCakDir.runandwait(programpath,Programparam : string);
- Var
- sei:SHELLEXECUTEINFO;
- FileToOpen,Param:array[0..255] of char;
- k : string;
- i : integer;
- Begin
- cancelwait := false;
- terminaterun := false;
- if uppercase(extractfileext(programpath)) = '.INF' then
- begin
- execinf(programpath,k);
- exit;
- end;
- if uppercase(extractfileext(programpath)) = '.REG' then
- begin
- execreg(programpath);
- exit;
- end;
- // Get the file to use
- StrPCopy(FileToOpen,programpath);
- StrPCopy(Param,programparam);
- // Run (exe), open (documents) or install (inf)
- // the file using ShellExecuteEx
- sei.cbSize:=sizeof(sei);
- sei.fMask:=SEE_MASK_FLAG_DDEWAIT or SEE_MASK_NOCLOSEPROCESS;
- sei.wnd:= Application.MainForm.handle;
- if(strpos(FileToOpen,'.inf')<>nil) then
- sei.lpVerb:='Install'
- else
- sei.lpVerb:=nil;
- sei.lpFile:=FileToOpen;
- if programparam <> '' then
- sei.lpParameters:=Param else
- sei.lpParameters:=nil;
- sei.lpDirectory:=nil;
- sei.nShow:=SW_SHOWDEFAULT;
- if(ShellExecuteEx(@sei)=true) then
- begin
- // Wait for it to terminate
- WaitForInputIdle(sei.hProcess,1000);
- while(WaitForSingleObject(sei.hProcess,10)=WAIT_TIMEOUT) and not cancelwait and not terminaterun do
- begin
- // Keep watch for messages so that we
- // don't appear to "stop responding"
- Application.ProcessMessages();
- Sleep(500);
- end;
- i := 0;
- if terminaterun then
- TerminateProcess(sei.hProcess,i);
- CloseHandle(sei.hProcess);
- end
- else
- MessageBox(Application.Mainform.Handle,'Unable to run or open this file',pchar(Application.Mainform.caption),mb_ok or mb_iconstop);
- end;
-
- function TCakDir.sizeinK(size: int64): string;
- var
- j: real;
- k : string;
- begin
- if size = 0 then
- Result := '0 kb'
- else
- begin
- j := (size / 1000);
- if j <= 999.99 then
- k := FormatFloat('##0.00', j)
- else
- k := FormatFloat('###,###,###,##0', j);
- Result := k + ' kb';
- end;
- end;
-
- function TCakDir.isharddrive(drive : char) : boolean;
- begin
- result := (GetDriveType(pchar(drive + ':\')) = DRIVE_FIXED);
- end;
- function TCakDir.iscdrom(drive : char) : boolean;
- begin
- result := (GetDriveType(pchar(drive + ':\')) = DRIVE_CDROM);
- end;
- function TCakDir.isfloppy(drive : char) : boolean;
- begin
- result := (GetDriveType(pchar(drive + ':\')) = DRIVE_REMOVABLE);
- end;
-
- {$IFDEF USE_SHCN}
- procedure TCakDir.MonitorStart;
- begin
- SHCN := TSHChangeNotify.Create(Application.MainForm);
- History := TStringList.Create;
- History.Clear;
- SHCN.OnAttributes := CNOnAttrib;
- SHCN.OnCreate := CNOnCreate;
- SHCN.OnDelete := CNOnDelete;
- SHCN.OnMkDir := CNOnNewDir;
- SHCN.OnRenameFolder := CNOnRename;
- SHCN.OnRenameItem := CNOnRename;
- SHCN.OnRmDir := CNOnRmDir;
- SHCN.OnUpdateDir := CNOnUpdateDir;
- SHCN.OnUpdateItem := CNOnUpdateItem;
- SHCN.Execute;
- //A_HKCU := MakeRegnode(HKEY_CURRENT_USER,'');
- //A_HKLM := MakeRegnode(HKEY_LOCAL_MACHINE,'');
- History.Add(MSG_BEGINLOG);
- end;
- {$ENDIF}
- {$IFDEF USE_SHCN}
- procedure TCakDir.MonitorStop;
- begin
- SHCN.Stop;
- SHCN.Free;
- //CleanRegNode(A_HKCU);
- //CleanRegNode(A_HKLM);
- History.Free;
- end;
- {$ENDIF}
- {$IFDEF USE_SHCN}
- procedure TCakDir.CNOnAttrib(Sender: TObject; Flags: Cardinal;Path1: String);
- begin
- //if pos(Grabtemppath,path1) = 0 then
- history.Add('Attrib Changed : ' + Path1);
- end;
- {$ENDIF}
- {$IFDEF USE_SHCN}
- procedure TCakDir.CNOnCreate(Sender: TObject; Flags: Cardinal;Path1: String);
- begin
- //if pos(Grabtemppath,path1) = 0 then
- history.Add('Created : ' + Path1);
- end;
- {$ENDIF}
- {$IFDEF USE_SHCN}
- procedure TCakDir.CNOnDelete(Sender: TObject; Flags: Cardinal;Path1: String);
- begin
- //if pos(Grabtemppath,path1) = 0 then
- history.Add('Deleted : ' + path1);
- end;
- {$ENDIF}
- {$IFDEF USE_SHCN}
- procedure TCakDir.CNOnNewDir(Sender: TObject; Flags: Cardinal;Path1: String);
- begin
- //if pos(Grabtemppath,path1) = 0 then
- history.Add('Directory Created : ' + Path1);
- end;
- {$ENDIF}
- {$IFDEF USE_SHCN}
- procedure TCakDir.CNOnRename(Sender: TObject; Flags: Cardinal;Path1, path2: String);
- begin
- //if pos(Grabtemppath,path1) = 0 then
- history.Add('Renamed : ' + Path1 + '->' + Path2 );
- end;
- {$ENDIF}
- {$IFDEF USE_SHCN}
- procedure TCakDir.CNOnRmDir(Sender: TObject; Flags: Cardinal;Path1: String);
- begin
- //if pos(Grabtemppath,path1) = 0 then
- history.Add('Directory Removed : ' + Path1);
- end;
- {$ENDIF}
- {$IFDEF USE_SHCN}
- procedure TCakDir.CNOnUpdateDir(Sender: TObject; Flags: Cardinal;Path1: String);
- begin
- //if pos(Grabtemppath,path1) = 0 then
- history.Add('Directory Updated : ' + Path1);
- end;
- {$ENDIF}
- {$IFDEF USE_SHCN}
- procedure TCakDir.CNOnUpdateItem(Sender: TObject; Flags: Cardinal;Path1: String);
- begin
- //if pos(Grabtemppath,path1) = 0 then
- history.Add('Updated : ' + Path1);
- end;
- {$ENDIF}
-
- procedure TCakDir.Explorefolder(folder : string);
- begin
- ShellExecute(application.handle,'open',PCHAR(folder),'',
- PCHAR(folder),SW_SHOWNORMAL);
- end;
-
- function TCakDir.newtemppath : string;
- var i : integer;
- k : string;
- begin
- i := Gettickcount;
- While Directoryexists(Grabtemppath + inttostr(i)) do
- inc(i);
- k := Grabtemppath + inttostr(i) + '\';
- MakeDirectory(k);
- NewDirList.Add(k);
- result := k;
- end;
-
- procedure TCakdir.ExecReg(Var Path : string);
- var k : string;
- begin
- k := '/s /y ' + path;
- Shellexecute(application.handle,'open','Regedit.exe',
- pchar(k), pchar(grabwindowpath), SW_NORMAL);
- end;
-
- Function TCakDir.ExecInf( Var Path, Param: String ): Cardinal;
- Var
- osvi: TOSVersionInfo;
- Begin
- Result:=0;
-
- if Param = '.ntx86'
- then
- Param := Param + ' '
- else
- Param := '';
-
- osvi.dwOSVersionInfoSize := SizeOf( OSvi );
- If GetVersionEx( OSVI ) Then
- Begin
- Case osvi.dwPlatformID Of
- VER_PLATFORM_WIN32_WINDOWS: Path := 'rundll.exe setupx.dll,InstallHinfSection DefaultInstall 132 ' + Path;
- VER_PLATFORM_WIN32_NT: Path := 'rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall' +
- Param + '132 ' + Path;
- End;
- Result := WinExec( pChar( Path ), SW_SHOW );
- End;
- End;
-
- {$IFDEF USE_ZIPR}
- procedure TCakDir.repairZip(SourceName, DestName : string);
- begin
- Ziprepair.RepairZip(SourceName,DestName);
- end;
- {$ENDIF}
-
- procedure TCakDir.SendMail(Subject, Mailtext,
- FromName, FromAdress,
- ToName, ToAdress,
- AttachedFileName,
- DisplayFileName: string;
- ShowDialog: boolean);
- var
- MapiMessage: TMapiMessage;
- MError: cardinal;
- Empfaenger: array[0..1] of TMapiRecipDesc;
- Absender: TMapiRecipDesc;
- Datei: array[0..1] of TMapiFileDesc;
- begin
- with MapiMessage do
- begin
- ulReserved := 0;
- lpszSubject := PChar(Subject);
- lpszNoteText := PChar(Mailtext);
- lpszMessageType := nil;
- lpszDateReceived := nil;
- lpszConversationID := nil;
- flFlags := 0;
- Absender.ulReserved := 0;
- Absender.ulRecipClass := MAPI_ORIG;
- Absender.lpszName := PChar(FromName);
- Absender.lpszAddress := PChar(FromAdress);
- Absender.ulEIDSize := 0;
- Absender.lpEntryID := nil;
- lpOriginator := @Absender;
- nRecipCount := 1;
- Empfaenger[0].ulReserved := 0;
- Empfaenger[0].ulRecipClass := MAPI_TO;
- Empfaenger[0].lpszName := PChar(ToName);
- Empfaenger[0].lpszAddress := PChar(ToAdress);
- Empfaenger[0].ulEIDSize := 0;
- Empfaenger[0].lpEntryID := nil;
- lpRecips := @Empfaenger;
- nFileCount := 1;
- Datei[0].lpszPathName := PChar(AttachedFilename);
- Datei[0].lpszFileName := PChar(DisplayFilename);
- Datei[0].ulReserved := 0;
- Datei[0].flFlags := 0;
- Datei[0].nPosition := cardinal(-1);
- Datei[0].lpFileType := nil;
- lpFiles := @Datei;
- end;
- // Senden
- if ShowDialog then
- MError := MapiSendMail(0, application.Handle, MapiMessage,
- MAPI_DIALOG or MAPI_LOGON_UI or MAPI_NEW_SESSION, 0)
- else
- // Wenn kein Dialogfeld angezeigt werden soll:
- MError := MapiSendMail(0, Application.Handle, MapiMessage, 0, 0);
- case MError of
- //MAPI_E_AMBIGUOUS_RECIPIENT:
- // MessageDlg('EmpfΣnger nicht eindeutig. (Nur m÷glich, wenn Emailadresse nicht angegeben.)',mterror,[mbok],0);
- MAPI_E_ATTACHMENT_NOT_FOUND:
- MessageDlg('Cannot find the attachment', mtError, [mbOK], 0);
- MAPI_E_ATTACHMENT_OPEN_FAILURE:
- MessageDlg('Cant open the attachment.', mtError, [mbOK], 0);
- MAPI_E_BAD_RECIPTYPE:
- MessageDlg('BAD MAPI_TO, MAPI_CC or MAPI_BCC.', mtError, [mbOK], 0);
- MAPI_E_FAILURE:
- MessageDlg('Unknown error.', mtError, [mbOK], 0);
- MAPI_E_INSUFFICIENT_MEMORY:
- MessageDlg('Not enough memory.', mtError, [mbOK], 0);
- MAPI_E_LOGIN_FAILURE:
- MessageDlg('Unable to login.', mtError, [mbOK], 0);
- MAPI_E_TEXT_TOO_LARGE:
- MessageDlg('Text too large', mtError, [mbOK], 0);
- MAPI_E_TOO_MANY_FILES:
- MessageDlg('Too many files.', mtError, [mbOK], 0);
- MAPI_E_TOO_MANY_RECIPIENTS:
- MessageDlg('Too many recipients.', mtError, [mbOK], 0);
- MAPI_E_UNKNOWN_RECIPIENT: MessageDlg('Unknown receipients', mtError, [mbOK], 0);
- MAPI_E_USER_ABORT:
- MessageDlg('User Abort!', mtError, [mbOK], 0);
- SUCCESS_SUCCESS:
- begin
- end;
- end;
- end;
-
- procedure TCakDir.BatchAdd(afilelist : TStrings;archivetype : supporttype);
- var i : integer;
- begin
- for i := 0 to afilelist.count -1 do
- begin
- Clear_archive_list;
- New_archive(removefileext(afilelist.strings[i]) + '.' + getarcstring(archivetype));
- addoptions.add_to := 0;
- addoptions.add_files.clear;
- addoptions.add_files.add(afilelist.strings[i]);
- add;
- end;
- end;
-
- function TCakDir.MakeRegnode(rootkey : HKEY; path : ANSIstring) : Tlist;
- var
- alist : TList;
- anode,asubnode : PRegnodetype;
- keylist,subkeylist : tstrings;
- i : integer;
- begin
-
- alist := TList.create;
- alist.clear;
-
- keylist := RegListval(rootkey,path);
- subkeylist := Reglistsubkey(rootkey,path);
-
- for i := 0 to keylist.count-1 do
- begin
- New(anode);
- anode^.iskey := true;
- anode^.subkey := TList.Create;
- //anode^.valuetype :=Reg.GetDataType(keylist.strings[i]);
- anode^.fullpath := path + '\' + keylist.strings[i];
- anode^.keyname := keylist.strings[i];
-
- alist.add(anode);
- {anode^.dataS := '';
- anode^.dataES := '';
- anode^.dataI := 0;
- anode^.dataB := 0;
- Case anode^.valuetype of
- rdString : anode^.dataS := Reg.ReadString(keylist.strings[i]);
- rdExpandString : anode^.dataES := Reg.ReadString(keylist.strings[i]);
- rdInteger : anode^.dataI := Reg.ReadInteger(keylist.strings[i]);
- rdBinary : anode^.dataB := 0//Reg.ReadBinaryData(keylist.strings[i],j,2147483647);
-
- end;}
- end;
-
-
- for i := 0 to subkeylist.count -1 do
- begin
- New(asubnode);
- asubnode^.iskey := false;
- asubnode^.fullpath := path + '\' + subkeylist.strings[i];
- asubnode^.keyname := subkeylist.strings[i];
- asubnode^.subkey := TList.create;
- asubnode^.subkey := MakeRegnode(rootkey,asubnode^.fullpath);
- alist.Add(asubnode);
- end;
-
- keylist.Free;
- subkeylist.free;
- result := alist;
- end;
-
- procedure TCakDir.CleanRegnode(alist : TList);
- var i: integer;
- anode : PRegnodetype;
- begin
- for i := alist.Count -1 downto 0 do
- begin
- anode := alist.Items[i];
- CleanRegnode(anode^.subkey);
- Dispose(anode);
- end;
- end;
-
- function TCakDir.name2rkey(key : string) : HKey;
- var k : string;
- begin
- k := Uppercase(Key);
- Result := HKEY_CLASSES_ROOT;
- if k = 'HKCR' then
- Result := HKEY_CLASSES_ROOT else
- if k = 'HKCU' then
- Result := HKEY_CURRENT_USER else
- if k = 'HKLL' then
- Result := HKEY_LOCAL_MACHINE else
- if k = 'HKU' then
- Result := HKEY_USERS else
- if k = 'HKCC' then
- Result := HKEY_CURRENT_CONFIG else
- if k = 'HKDD' then
- Result := HKEY_DYN_DATA;
- end;
-
- function TCakdir.rkeyname(rootkey :HKEY) : string;
- begin
- Case rootkey of
- HKEY_CLASSES_ROOT : result := 'HKEY_CLASSES_ROOT';
- HKEY_CURRENT_USER : result := 'HKEY_CURRENT_USER';
- HKEY_LOCAL_MACHINE : result := 'HKEY_LOCAL_MACHINE';
- HKEY_USERS : result := 'HKEY_USERS';
- HKEY_CURRENT_CONFIG : result := 'HKEY_CURRENT_CONFIG';
- HKEY_DYN_DATA : result := 'HKEY_DYN_DATA';
- else result := '??';
- end;
- end;
-
-
- procedure TCakDir.AddRegnode(Rootkey : Hkey; alist : TList;var astring : TStrings;key, subkey : string);
- var i: integer;
- anode : PRegnodetype;
- begin
- astring := Tstringlist.Create;
- for i := alist.Count -1 downto 0 do
- begin
- anode := alist.Items[i];
- if not anode^.iskey then
- astring.Add(subkey + rkeyname(rootkey) + anode^.fullpath) else
- astring.Add(key + rkeyname(rootkey) + anode^.fullpath);
- if not anode^.iskey then
- AddRegnode(Rootkey,anode^.subkey,astring,key,subkey);
- end;
- end;
-
- procedure TCakDir.CompareRegnode(rootkey :HKEY; list1,list2 : TList; var astring : TStrings; key,subkey : string);
- var i,j: integer;
- node1, node2 : PRegnodetype;
- bstring : TStrings;
- begin
- bstring := TStringList.create;
- for i := 0 to list2.count -1 do
- begin
- node2 := list2.items[i];
- if node2^.iskey then
- begin
- j := 0;
- if list1.count > 0 then
- begin
- node1 := list1.Items[j];
- While ((not node1^.iskey) or (node1^.fullpath <> node2^.fullpath)) and (j < list1.count) do
- begin
- node1 := list1.Items[j];
- inc(j);
- end;
- if (node1^.fullpath <> node2^.fullpath) then
- astring.add(key + rkeyname(rootkey) + node2^.fullpath);
-
- end else if list2.count > 0 then astring.add(key + rkeyname(rootkey) + node2^.fullpath)
- end
- else
-
- begin
- j := 0;
- if list1.count > 0 then
- begin
- node1 := list1.Items[j];
- While ((node1^.iskey) or (node1^.fullpath <> node2^.fullpath)) and (j < list1.count) do
- begin
- node1 := list1.Items[j];
- inc(j);
- end;
- if (node1^.fullpath = node2^.fullpath) then
- CompareRegNode(rootkey,node1^.subkey,node2^.subkey, astring,key,subkey)
- else
- begin
- astring.add(subkey + rkeyname(rootkey) + node2^.fullpath);
- AddRegnode(rootkey,node2^.subkey,bstring,key,subkey);
- astring.addstrings(bstring);
- end;
-
- end else if list2.count > 0 then astring.add(subkey + rkeyname(rootkey) + node2^.fullpath);
- end;
-
-
- end;
- bstring.free;
- end;
-
- {$IFDEF USE_SHCN}
- function TCakDir.MonitorShowChanges : TStrings;
- var astring,bstring : TStrings;
- B_HKCU,B_HKLM : TList;
- begin
- astring := TStringlist.create;
- bstring := TStringlist.create;
- astring.AddStrings(history);
- {
- B_HKCU := MakeRegnode(HKEY_CURRENT_USER,'');
- CompareRegnode(HKEY_CURRENT_USER,A_HKCU,B_HKCU,bstring,'newkey:','newsubkey:');
- CompareRegnode(HKEY_CURRENT_USER,B_HKCU,A_HKCU,bstring,'delkey:','delsubkey:');
- CleanRegNode(B_HKCU);
- astring.AddStrings(bstring);
- bstring.clear;
-
- B_HKLM := MakeRegnode(HKEY_LOCAL_MACHINE,'');
- CompareRegnode(HKEY_LOCAL_MACHINE,A_HKLM,B_HKLM,bstring,'newkey:','newsubkey:');
- CompareRegnode(HKEY_LOCAL_MACHINE,B_HKLM,A_HKLM,bstring,'delkey:','delsubkey:');
- CleanRegNode(B_HKLM);
- astring.AddStrings(bstring);
- bstring.clear;
-
- bstring.Free;
- }
- result := astring;
- end;
- {$ENDIF}
-
-
- function TCakDir.SubDirList(dir : string) : TStrings;
- var
- sr: TSearchRec;
- FileAttrs : integer;
- aStrings : TStrings;
- k : string;
- begin
- aStrings := TStringList.create;
- FileAttrs := 0;
- FileAttrs := FileAttrs + faDirectory;
- k := Appendslash(dir);
- if FindFirst(k + '*', FileAttrs, sr) = 0 then
- begin
- if Directoryexists(k + sr.Name) then
- if (sr.name <> '.') and (sr.name <> '..') then
- aStrings.add(AppendSlash(k+sr.Name));
- while (FindNext(sr) = 0) do
- if Directoryexists(k + sr.Name) then
- if (sr.name <> '.') and (sr.name <> '..') then
- aStrings.add(AppendSlash(k+sr.Name));
- FindClose(sr);
- end;
- result := aStrings;
- end;
-
- procedure TCakDir.FindStop;
- begin
- afinder.Terminate;
- end;
-
- procedure TCakDir.Find;
- begin
- aFinder := TFinder.Create(true);
- aFinder.OnCArchiveFound := FOnFound;
- FinderOptions.af_sourcedir := AppendSlash(FinderOptions.af_sourcedir);
- aFinder.FOption := FinderOptions;
- aFinder.Execute;
- aFinder.FreeOnTerminate := true;
- aFinder.Free;
- end;
-
-
-
- procedure TCakDir.Load_Script(script : TStrings);
- var i,j,k,l,m,scriptcount : integer;
- commands : Tstrings;
- x,s,s1,var1 : string;
- //opendialog : TOpendialog;
- begin
- commands := TStringList.Create;
- if assigned(script) then
- try
- var1 := scriptvar1;
- scriptcount := script.Count - 1;
- i := -1;
- While i < scriptcount do
- begin
- inc(i);
- if loadlines then
- if assigned(FOnMsg) then
- FOnMsg(nil,0,'Loading lines ' + inttostr(i));
- commands.clear;
- s := script.strings[i];
- While s <> '' do
- begin
- k := 0;
- j := pos('"',s);
- if j > 0 then
- begin
- s1 := Copy(s,j+1,length(s)-j);
- k := pos('"',s1);
- if k <> 0 then
- commands.add(Copy(s,j+1,k-1));
- end;
- if k <> 0 then
- s := Copy(s1,k+1,length(s)-k) else
- s := '';
- end;
-
- for j := 0 to Commands.count -1 do
- begin
- s := Uppercase(Commands.strings[J]);
- k := pos('%1%',s);
- if k <> 0 then
- begin {e.g. arc.exe c:\test.txt, var1 = ''}
- if var1 = '' then {e.g. arc.exe /macro1 c:\test.txt, var1 = c:\test.txt}
- if ScriptParam.Count > 0 then
- begin
- for l := 0 to scriptParam.count -1 do
- begin
- s1 := script.strings[i];
- m := pos('%1%',s1);
- while m <> 0 do
- begin
- s1 := Copy(s1,0,m-1) +
- scriptparam.strings[l] +
- Copy(s1,m + 3, length(s1) - m - 2);
- m := pos('%1%',s1);
- end;
-
- script.insert(i+1, s1);
-
- if assigned(FOnMSg) then
- FOnMsg(nil,0,'added '+ s1);
- end;
- script.Strings[i] := 'NOCMD';
- commands.Strings[0] := 'NOCMD';
- var1 := '';
- {var1 := ScriptParam.Strings[0];
-
- k := pos('"',script.strings[i]) + 1;
- for l := 1 to scriptParam.count -1 do
- begin
-
- s1 := Copy(script.strings[i],0,k-1);
- s1 := s1 + ScriptParam.strings[l];
- s1 := s1 + Copy(script.strings[i],k + 3,length(script.strings[i]) - k - 2);
-
- script.insert(i+1, s1);
- end;
- }
- end else
- if Paramcount > 1 then if fileexists(Paramstr(2)) then
- if Uppercase(Extractfileext(Paramstr(2))) <> '.AKS' then
- var1 := Paramstr(2);
-
- { if var1 = '' then
- begin
- opendialog := TOpendialog.Create(nil);
- if opendialog.execute then
- var1 := opendialog.FileName;
- opendialog.free;
- end; }
-
- if var1 <> '' then
- Commands.Strings[j] := var1 + Copy (Commands.strings[j],4,Length(s)-3);
- scriptcount := script.Count - 1;
- end;
-
- k := pos('%TEMP%\',s);
- if k = 1 then
- Commands.Strings[j] := GrabTEMPpath + Copy(Commands.strings[J],8,length(s)-7);
- k := pos('%WINDOWS%\',s);
- if k = 1 then
- Commands.Strings[j] := GrabWINDOWpath + Copy(Commands.strings[J],11,length(s)-10);
- k := pos('%DESKTOP%\',s);
- if k = 1 then
- Commands.Strings[j] := GrabDESKTOPpath + Copy(Commands.strings[J],11,length(s)-10);
- k := pos('%ARCHIVE%\',s);
- if k = 1 then
- if Total_Archive > 0 then
- Commands.Strings[j] := Appendslash(Extractfilepath(Archive_List[0]._Arcname)) + Copy(Commands.strings[J],11,length(s)-10);
- end;
-
- s := Uppercase(script.strings[i]);
-
- if pos('NEW ',s) = 1 then
- if commands.count >= 0 then
- if not fileexists(commands.strings[0]) then
- New_archive(commands.strings[0]) else
- begin
- l := 0;
- x := Format('%s%d%s',[removefileext(commands.strings[0]), l,extractfileext(commands.strings[0])]);
- While (l <= 99) and fileexists(x) do
- begin
- inc(l);
- x := Format('%s%d%s',[removefileext(commands.strings[0]), l,extractfileext(commands.strings[0])]);
- end;
-
-
- if not fileexists(x) then
- New_Archive(x) else
- begin
- Add_Archive_List(commands.strings[0]);
- List_archive(0,0);
- end;
- end;
-
- if pos('CLOSE ',s) = 1 then
- Clear_archive_List;
-
- if pos('OPEN ',s) = 1 then
- if commands.count >= 0 then
- if fileexists(commands.strings[0]) then
- begin
- Add_Archive_List(commands.strings[0]);
- List_archive(0,0);
- end
- else
- New_archive(commands.strings[0]);
-
- if pos('EXTR ',s) = 1 then
- if Total_Archive > 0 then
- if commands.count >= 2 then
- begin
- Mask_Add_selected_List(commands.strings[0],Archive_List[0]._Arcname);
- Extractoptions.extr_to := Commands.strings[1];
- Extract;
- end;
-
- if pos('ADD ',s) = 1 then
- if Total_Archive > 0 then
- if commands.count > 0 then
- begin
- AddOptions.add_to := Total_Archive-1;
- AddOptions.add_files.Add(commands.strings[0]);
- end;
-
- if pos('CONVERT ',s) = 1 then
- if commands.count > 1 then
- begin
- Archive_Convert(commands.strings[0],Getarctype('xyz.'+commands.strings[1]));
- end;
-
- if pos('SYNC ',s) = 1 then
- if Total_Archive > 0 then
- if commands.count > 0 then
- begin
- AddOptions.add_to := Total_Archive-1;
-
- if AddOptions.add_Usepath then
- j := Get_Archive_Code(Archive_List[0]._arcname,removedrive(commands.strings[0])) else
- j := Get_Archive_Code(Archive_List[0]._arcname,extractfilename(commands.strings[0]));
-
- if j <> -1 then
- begin
- if FileDateToDateTime(FileAge(commands.strings[0])) > archive_contents[j]._FileTime then
- AddOptions.add_files.Add(commands.strings[0]);
- end;
- end;
-
- if pos('DOADD',s) = 1 then
- if Total_Archive > 0 then
- if AddOptions.add_files.count > 0 then
- Add;
-
- if pos('DEL ',s) = 1 then
- if Total_Archive > 0 then
- if commands.count > 0 then
- begin
- Mask_Add_selected_List(commands.strings[0],Archive_List[0]._Arcname);
- Delete
- end;
-
- if pos('REN ',s) = 1 then
- if Total_Archive > 0 then
- if Archive_List[0]._Arctype = _ZIP then
- if commands.count > 1 then
- if Get_Archive_Code(Archive_List[0]._Arcname,commands.strings[0]) <> -1 then
- if Get_Archive_Code(Archive_List[0]._Arcname,commands.strings[1]) = -1 then
- Zipdirrename(commands.strings[0],commands.strings[1]);
-
- if pos('RENDIR ',s) = 1 then
- if Total_Archive > 0 then
- if Archive_List[0]._Arctype = _ZIP then
- if commands.count > 1 then
- Zipdirrenamedir(commands.strings[0],commands.strings[1]);
-
- if pos('PASSWORD ',s) = 1 then
- if commands.count > 0 then
- AddOptions.add_encrypt := commands.strings[0] else
- AddOptions.add_encrypt := '';
-
- AddOptions.add_useencrypt := (AddOptions.add_encrypt <> '');
-
- if pos('VERSIONCONTROL ',s) = 1 then
- if commands.count > 0 then
- if Uppercase(Commands.strings[0]) = 'ON' then
- versioncontrol := true else
- if Uppercase(Commands.strings[0]) = 'OFF' then
- versioncontrol := false;
-
- if pos('USEEXTRPATH ',s) = 1 then
- if commands.count > 0 then
- if Uppercase(Commands.strings[0]) = 'ON' then
- Extractoptions.extr_DirNames := true else
- if Uppercase(Commands.strings[0]) = 'OFF' then
- Extractoptions.extr_DirNames := false;
-
- if pos('USEADDPATH ',s) = 1 then
- if commands.count > 0 then
- if Uppercase(Commands.strings[0]) = 'ON' then
- Addoptions.add_usepath := true else
- if Uppercase(Commands.strings[0]) = 'OFF' then
- Addoptions.add_usepath := false;
-
- if pos('USESUBDIR ',s) = 1 then
- if commands.count > 0 then
- if Uppercase(Commands.strings[0]) = 'ON' then
- Addoptions.add_subdir := true else
- if Uppercase(Commands.strings[0]) = 'OFF' then
- Addoptions.add_subdir := false;
-
-
- if pos('RUNFILE ',s) = 1 then
- Case commands.count of
- 1 : Run(commands.strings[0],'');
- 2 : Run(commands.strings[0],commands.strings[1]);
- end;
-
- if pos('MOVEFILE ',s) = 1 then
- if commands.count > 1 then
- Movefile(PCHAR(commands.strings[0]),PCHAR(commands.strings[1]));
-
- if pos('RENFILE ',s) = 1 then
- if commands.count > 1 then
- Renamefile(commands.strings[0],commands.strings[1]);
-
- if pos('DELFILE ',s) = 1 then
- if commands.count > 0 then
- if fileexists(commands.strings[0]) then
- deletefile(commands.strings[0]);
-
- if pos('BACKUPREG ',s) = 1 then
- if commands.count > 3 then
- RegBackup(name2rkey(commands.strings[0]),commands.strings[1],commands.strings[2],commands.strings[3]);
-
- if pos('TXTFLIST ',s) = 1 then
- if commands.count > 0 then
- FileList(_txt,commands.strings[0],0,total_archive -1);
-
- if pos('HTMFLIST ',s) = 1 then
- if commands.count > 0 then
- FileList(_htm,commands.strings[0],0,total_archive -1);
-
- if pos('PDFFLIST ',s) = 1 then
- if commands.count > 0 then
- FileList(_pdf,commands.strings[0],0,total_archive -1);
-
- if pos('PDF2FLIST ',s) = 1 then
- if commands.count > 0 then
- FileList(_pdf2,commands.strings[0],0,total_archive -1);
-
- if pos('SPAN ',s) = 1 then
- if commands.count > 2 then
- DiskSpan(commands.strings[0],commands.strings[1],strtointdef(commands.strings[2],1000*1024),true);
-
- if pos('MSG ',s) = 1 then
- if commands.count > 0 then
- if assigned(FOnMsg) then
- FOnMsg(nil,0,commands.strings[0]);
-
- if pos('EMAIL ',s) = 1 then
- if commands.count > 0 then
- Sendmail('Subject','','','','',commands.strings[0],Archivename,Extractfilename(Archivename),true);
-
- if pos('BATCHADD ',s) = 1 then
- if commands.count > 1 then
- begin
-
- Archivename := commands.Strings[1];
- AddOptions.add_files.Clear;
- AddOptions.add_files.Add(commands.Strings[0]);
- Add;
- Clear_Archive_List;
- end;
-
- if pos('CLOSEARC',s) = 1 then
- Application.Terminate;
- end;
- except
- if assigned(FOnMsg) then
- FOnMsg(nil,0,'Error Loading Script');
- end;
-
- commands.Free;
- end;
-
- procedure TCakDIr.DiskUnSpan(filename : string);
- var tf,sf : file;
- buf : array[1..500] of byte;
- textf : tstrings;
- numread : longint;
- i : integer;
- begin
- textf := Tstringlist.create;
- textf.LoadFromFile(filename);
- Assignfile(tf,textf.strings[0]);
- Rewrite(tf,1);
- For i := 1 to textf.count -1 do
- begin
- Assignfile(sf,textf.strings[i]);
- Reset(sf,1);
- While numread > 0 do
- begin
- Blockread(sf,buf,sizeof(buf),numread);
- BlockWrite(tf,buf,numread);
- end;
- Closefile(sf);
- end;
- Closefile(tf);
- textf.free;
- end;
- function TCakDir.DiskSpan(source, target : string; disksize : longint; MakeBatch : boolean) : integer;
- const BREAK = #13#10;
- batadd1 = '@echo off'+BREAK+
- 'set lbl=a'+BREAK+
- 'goto logo'+BREAK+
- ':a'+BREAK+
- 'if "%1"=="/auto" goto b'+BREAK+
- 'choice /C:yn /N /T:Y,3 Reconstruct archive [will default to Yes in 3 secs]?'+BREAK+
- 'echo.'+BREAK+
- 'if errorlevel 2 goto end'+BREAK+
- ':b'+BREAK+
- 'set lbl=c'+BREAK+
- 'goto logo'+BREAK+
- ':c'+BREAK+
- 'echo Reconstructing archive, please wait.....';
- batadd2 = 'Echo ....done'+BREAK+
- 'goto end'+BREAK+
- ':logo'+BREAK+
- 'cls'+BREAK+
- 'Echo ' + PRODUCT + ' UnSpanner'+BREAK+
- 'Echo.'+BREAK+
- 'Echo Copyright (c) Joseph Leung, 1999-2001'+BREAK+
- 'echo.'+BREAK+
- 'goto %lbl%'+BREAK+
- ':end'+BREAK+
- 'echo.'+BREAK+
- 'echo Press any key to exit...'+BREAK+
- 'if not "%1"=="/auto" pause > nul'+BREAK+
- 'cls';
-
- var tf,sf : file;
- textf : textfile;
- fsize,remainsize : longint;
- buf : array[1..500] of byte;
- numread : longint;
- disk : integer;
- k,l : string;
- i : integer;
- begin
- Assignfile(sf,source);
- Reset(sf,1);
- fsize := Filesize(sf);
- Seek(sF,0);
- disk := 0;
- while fsize > 0 do
- begin
- inc(disk);
- Assignfile(tf,target + '.' + inttostr(disk));
- Rewrite(tf,1);
- remainsize := disksize;
- numread := -1;
- while (remainsize >= 0) and (numread <> 0) do
- begin
- BlockRead(sf,buf,sizeof(buf),numread);
- Dec(Remainsize,numread);
- if numread > 0 then
- BlockWrite(tf,Buf,numread);
- end;
- if Isfloppy(source[1]) then
- Writeln('Please insert another floppy disk');
-
- Closefile(tf);
- Dec(fsize,disksize);
- end;
- Closefile(sf);
- k := extractfilename(target);
- l := extractfilename(source);
-
- Assignfile(textf,target + '.x');
- Rewrite(textf);
- writeln(textf,l);
- for i := 1 to disk do
- Write(textf,k + '.' + inttostr(i));
- Closefile(textf);
-
- if MakeBatch then
- begin
- Assignfile(textf,target + '.bat');
- Rewrite(textf);
- Writeln(textf,batadd1);
-
- write(textf,'Copy /b ');
- Write(textf, k + '.1');
- for i := 2 to disk do
- Write(textf,'+' + k + '.' + inttostr(i));
- Writeln(textf,' ' + l + ' >nul');
-
- Writeln(textf,batadd2);
- Closefile(textf);
- end;
- result := disk;
- end;
-
- procedure TCakDir.ProcessAKS(processwhat : worktype);
- var astrings : TStrings;
- Cakdir2 : TCakDir;
- begin
- if processwhat <> _LoadContents then exit;
- if assigned(FOnMsg) then
- FOnMsg(nil,0,'Loading ' + Archive_List[0]._Arcname + ' now.');
- astrings := TstringList.Create;
- CakDir2 := TCakDir.Create(nil);
- if assigned(FOnMsg) then
- CakDir2.OnCMessage := FONMsg;
- try
- cakdir2.ScriptParam.AddStrings(scriptparam);
- CakDir2.scriptvar1 := scriptvar1;
- astrings.LoadFromFile(Archive_List[0]._Arcname);
- CakDir2.Load_Script(astrings);
- finally
- CakDir2.Free;
- astrings.free;
- if assigned(FOnMsg) then
- FOnMsg(nil,0,'Finish Loading.');
- end;
- end;
- procedure TCakDir.Filename_Truncate(arcname : string);
- var CakDir2 : TCakDir;
- i : integer;
- k : string;
- newfilename : string;
- begin
- CakDir2 := TCakDir.Create(nil);
- CakDir2.Set_Archive_List(arcname);
- CakDir2.List_Archive(0,0);
- k := Newtemppath;
- if CakDir2.cando(CakDir2.GetArctype(arcname),_Delete) then
- if CakDir2.cando(CakDir2.GetArctype(arcname),_Add) then
- With CakDir2 do
- begin
- Clear_Selected_List;
- for i := 0 to total_Contents -1 do
- if Archive_Contents[i]._FileDefPath = '' then
- if Length(Removefileext(Archive_Contents[i]._Filename)) > 8 then
- begin
- ExtractOptions.extr_to := k;
- ExtractOptions.extr_DirNames := false;
- ExtractOptions.extr_OverWrite := true;
- Archive_Contents[i]._Selected := true;
- Extract;
- Archive_Contents[i]._Selected := true;
-
- newfilename := Removefileext(Archive_Contents[i]._Filename);
- newfilename := Copy(newfilename,0,6) + '~1' + Extractfileext(Archive_Contents[i]._Filename);
- newfilename := k + newfilename;
- if Renamefile(k + archive_Contents[i]._filename,newfilename) then
- begin
- Delete;
- AddOptions.add_to := 0;
- AddOptions.add_files.Add(newfilename);
- Add;
- end;
- end;
- end;
- showmessage('Finished truncated');
- end;
-
- procedure TCakDir.Archive_Convert(filename : string; totype : supporttype);
- var i : integer;
- CakDir2 : TCakDir;
- k : string;
- astrings : TStrings;
- begin
- astrings := TstringList.Create;
- CakDir2 := TCakDir.Create(nil);
- try
- CakDir2.Set_Archive_List(filename);
- CakDir2.List_Archive(0,0);
- For i := 0 to CakDir2.Total_Contents -1 do
- astrings.Add(CakDir2.Archive_Contents[i]._Filename);
- CakDir2.Add_All_Selected_List;
- k := CakDir2.newtemppath;
- CakDir2.Extractoptions.extr_to := k;
- CakDir2.Extractoptions.extr_DirNames := false;
- cakdir2.Extractoptions.extr_ArcINArc := false;
- CakDir2.Extract;
-
- CakDir2.New_Archive(Removefileext(filename) + '.' + GetarcString(totype));
- CakDir2.AddOptions.add_files.Clear;
- For i := 0 to astrings.count -1 do
- CakDir2.AddOptions.add_files.Add(k + astrings.strings[i]);
- CakDir2.AddOptions.add_usepath := false;
- CakDir2.Add;
- finally
- CakDir2.Free;
- end;
- end;
-
- function TCakDir.CreateShortcut(linkfilename,filepath : string) : boolean;
- var k : string;
- begin
- k := filepath;
- if Links.CreateLink(k,
- linkfilename,
- Extractfilename(k)) = True then
- Result := true
- else
- Result := false;
- end;
-
- function TCakDir.DiskMakeImage(drive : integer; filename : string) : boolean;
- var F: TMemoryStream;
- FBuf: Pointer;
- nSize: integer;
- FSBR : PFSBR;
- begin
- Result := false;
- F := TMemoryStream.Create;
- FBuf := AllocMem(512);
- try
- if Extractfilename(filename) <> '' then
- if ReadFloppyFSBR(drive, FSBR) then
- if 1474560 = FSBR.BPB.BytesPerSector * FSBR.BPB.SectorsOnDrive then
- begin
- nsize := FSBR.BPB.BytesPerSector * FSBR.BPB.SectorsOnDrive;
- F.SetSize(nsize);
- F.Seek(0, 0);
- FreeMem(FBuf);
- FBuf := AllocMem(nSize);
- if not ReadSector(drive, 0 , FSBR.BPB.SectorsOnDrive, FBuf ) then
- if Assigned(FOnMsg) then
- FOnMsg(nil,0,'Error reading sector');
-
- F.Seek(0, 0);
- F.Write(FBuf^, nSize);
- F.Seek(0, 0);
- F.SaveToFile(filename);
- if Assigned(FOnMsg) then
- FOnMsg(nil,0,'Created ' + filename);
- Result := true;
- end;
- finally
- F.Free;
- FreeMem(FBuf);
- end;
- end;
-
- function TCakDir.DiskWriteImage(drive : integer; filename : string) : boolean;
- var F: TMemoryStream;
- FBuf: Pointer;
- nSize: integer;
- FSBR : PFSBR;
- begin
- Result := false;
- if not ReadFloppyFSBR(drive, FSBR) then
- begin
- if Assigned(FOnMsg) then
- FOnMsg(nil,0,'Floppy not ready');
- exit;
- end;
-
- if not DriveIsRemovable(drive) then
- begin
- if Assigned(FOnMsg) then
- FOnMsg(nil,0,'Not a Floppy');
- exit;
- end;
-
- if not DirectAccessAllowed(drive) then
- begin
- if Assigned(FOnMsg) then
- FOnMsg(nil,0,'Not accessable');
- exit;
- end;
- nsize := FSBR.BPB.BytesPerSector * FSBR.BPB.SectorsOnDrive;
- if 1474560 = nsize then
- begin
- F := TMemoryStream.Create;
- FBuf := AllocMem(512);
- try
- F.SetSize(nSize);
- F.Seek(0, 0);
- FreeMem(FBuf);
- FBuf := AllocMem(nSize);
- F.LoadfromFile(filename);
- F.Seek(0, 0);
- F.Read(FBuf^, nSize);
- F.Seek(0, 0);
-
- if not WriteSector(drive, 0 , FSBR.BPB.SectorsOnDrive, FBuf, $0000 ) then
- if Assigned(FOnMsg) then
- FOnMsg(nil,0,'Error writing sectors');
-
- FreeFloppyFSBR(FSBR);
- if Assigned(FOnMsg) then
- FOnMsg(nil,0,'Restored ' + filename);
- Result := true;
- finally
- F.Free;
- FreeMem(FBuf);
- end;
- end;
-
- end;
-
- {$IFDEF USE_ZIP}
- procedure TCakDir.SFX2ZIP(SFXname : string);
- begin
- Load_ZIP_DLL;
- Zipdir.ZipFileName := SFXname;
- Zipdir.ConvertZIP;
- end;
- {$ENDIF}
-
- procedure TCakDir.RegBackup(RKey : HKey; KeyPath, Value : string;filename : string);
- var vallist : Tstrings;
- subkeylist : Tstrings;
- tf : textfile;
- i : integer;
- begin
- if Value = '' then
- begin
- vallist := RegListval(RKey, Keypath);
- subkeylist := RegListsubkey(RKey,Keypath);
- for i := 0 to vallist.Count -1 do
- RegBackup(RKey,Keypath,vallist.strings[i],filename);
- for i := 0 to subkeylist.count -1 do
- RegBackup(RKey,Keypath + '\' + subkeylist.strings[i],'',filename);
- end else
- if GetvalinReg(RKey,Keypath,Value) <> '' then
- begin
- assignfile(tf,filename);
- if fileexists(filename) then
- Append(tf)
- else
- begin
- Rewrite(tf);
- Writeln(tf,'REGEDIT4');
- Writeln(tf);
- end;
-
- Writeln(tf,'[' + rkeyname(rkey) + '\' + keypath + ']');
- Write(tf, '"' + Value + '"=');
- Writeln(tf,'"' + GetvalinReg(RKey,Keypath,Value) + '"');
- Writeln(tf);
-
- Closefile(tf);
- end;
- end;
-
- function TCakDir.RegListsubkey(RKey : HKey; KeyPath : string) : TStrings;
- var keylist : TStrings;
- Reg: TRegistry;
- k : string;
- begin
- Reg := TRegistry.Create;
- keylist := TStringlist.create;
-
- Reg.RootKey := RKEY;
- k := keypath;
- if k = '' then k := '\';
-
- if Reg.OpenKey(K, False) then
- Reg.GetKeyNames(keylist);
- Reg.CloseKey;
- Reg.Free;
- Result := keylist;
- end;
- function TCakDir.RegListVal(RKey : HKey; KeyPath : string) : TStrings;
- var keylist : TStrings;
- Reg: TRegistry;
- k : string;
- begin
- Reg := TRegistry.Create;
- keylist := TStringlist.create;
-
- Reg.RootKey := RKEY;
- k := keypath;
- if k = '' then k := '\';
-
- if Reg.OpenKey(K, False) then
- Reg.GetValueNames(keylist);
- Reg.CloseKey;
- Reg.Free;
- Result := keylist;
- end;
-
- procedure TCakDir.CrytoZip;
- begin
- if Total_Archive = 0 then exit;
- if Archive_List[0]._ARCtype <> _ZIP then exit;
- processfrom := 0;
- processto := 0;
- processZIP(_CryptoZip);
- end;
-
- function TCakDir.DeleteAllFiles(FilesOrDir: string): boolean;
- { Sends files or directory to the recycle bin. }
- var
- F: TSHFileOpStruct;
- From: string;
- Resultval: integer;
- begin
- result := false;
- if length(filesordir) <= 3 then exit;// (delete root?)
- FillChar(F, SizeOf(F), #0);
- From := FilesOrDir + #0;
- Screen.Cursor := crHourGlass;
- try
- F.wnd := 0;
- F.wFunc := FO_DELETE;
- F.pFrom := PChar(From);
- F.pTo := nil;
-
- F.fFlags := FOF_ALLOWUNDO or
- FOF_NOCONFIRMATION or
- FOF_SIMPLEPROGRESS or
- FOF_FILESONLY;
-
- F.fAnyOperationsAborted := False;
- F.hNameMappings := nil;
- Resultval := ShFileOperation(F);
- Result := (ResultVal = 0);
- finally
- Screen.Cursor := crDefault;
- end;
- end;
-
- procedure TCakDir.SetDefaultTreasAs;
- begin
- TreatAsZip := DefaultTreatAsZip;
- TreatAsRar := DefaultTreatAsRar;
- TreatAsCab := DefaultTreatAsCab;
- TreatAsArj := DefaultTreatAsArj;
- TreatAsLha := DefaultTreatAsLha;
- TreatAsTar := DefaultTreatAsTar;
- TreatAsTgz := DefaultTreatAsTgz;
- TreatAsAce := DefaultTreatAsAce;
- TreatAsBz2 := DefaultTreatAsBz2;
- TreatAsBel := DefaultTreatAsBel;
- TreatAsGca := DefaultTreatAsGca;
- TreatAsBza := DefaultTreatAsBza;
- TreatAsRs := DefaultTreatAsRs;
- TreatAsCzip := DefaultTreatAsCzip;
- TreatAsYz1 := DefaultTreatAsYz1;
- TreatAsUue := DefaultTreatAsUue;
- TreatAsXxe := DefaultTreatAsXxe;
- TreatAsB64 := DefaultTreatAsB64;
- TreatAsPak := DefaultTreatAsPak;
- TreatAsAks := DefaultTreatAsAks;
- end;
-
- function TCakDir.Get_Archive_Name : string;
- begin
- if Total_Archive > 0 then
- result := Archive_List[0]._Arcname else
- result := '';
- end;
-
- procedure TCakDir.SetArchivetype(value : supportType);
- begin
- if Total_Archive > 0 then
- Archive_List[0]._Arctype := value;
- end;
-
- function TCakDir.GetArchivetype : supportType;
- begin
- if Total_Archive = 0 then
- Result := _WIT else
- Result := Archive_List[0]._Arctype;
- end;
-
- function TCakDir.CanAdd : boolean;
- begin
- if Total_Archive = 0 then
- result := false else
- Result := Cando(Archive_List[0]._Arctype,_Add);
- end;
-
- function TCakDir.CanExtract : boolean;
- begin
- if Total_Archive = 0 then
- result := false else
- Result := Cando(Archive_List[0]._Arctype,_Extract);
- end;
- function TCakdir.pollfilelist(maskedname : string;subdir : boolean) : tstrings;
- var sr : TSearchRec;
- astrings : tstrings;
- k : string;
- begin
- astrings := tstringlist.create();
- k := Appendslash(extractfilepath(maskedname));
-
- if FindFirst(maskedname,faAnyfile and faHidden,sr) = 0 then
- begin
- if (sr.name <> '.') and (sr.name <> '..') then
- if fileexists(k + sr.Name) then
- astrings.Add(k + sr.Name);
- while FindNext(sr) = 0 do
- if (sr.name <> '.') and (sr.name <> '..') then
- if fileexists(k + sr.Name) then
- astrings.Add(k + sr.Name);
-
- end;
- FindClose(sr);
-
- if subdir then
- if pos('*',maskedname) <> 0 then
- begin
- if FindFirst(Appendslash(extractfilepath(maskedname)) + '*.*',faDirectory + faHidden ,sr) = 0 then
- begin
-
- if (sr.name <> '.') and (sr.name <> '..') then
- if directoryexists(k + sr.name) then
- astrings.addstrings(pollfilelist(appendslash(k + sr.name) + Extractfilename(maskedname) ,subdir));
-
- While FindNext(sr) = 0 do
- if (sr.name <> '.') and (sr.name <> '..') then
- if directoryexists(k + sr.name) then
- astrings.addstrings(pollfilelist(appendslash(k + sr.name) + Extractfilename(maskedname) ,subdir));
-
- end;
- FindClose(sr);
- end;
-
- result := astrings;
-
- end;
-
- procedure TCakdir.GenerateIndex(path : string; masks : tstrings; Indexfilename,Contentfilename : string);
- var i,j : integer;
- FnHolder : tstringlist;
- dummy : tstrings;
- AvaliableChars : string;
- Lastchar : char;
- df : textfile;
- k : string;
- procedure TD;
- begin
- write(df,'<TD ALIGN=CENTER COLSPAN=3>');
- end;
- procedure TD2;
- begin
- write(df,'<TD>');
- end;
- procedure EndTD;
- begin
- write(df,'</TD>');
- end;
- procedure TR;
- begin
- write(df,'<TR>');
- end;
- procedure TR2;
- begin
- write(df,'<TR bgcolor="#FFFFCC">');
- end;
- procedure B;
- begin
- write(df,'<B>');
- end;
- procedure EndB;
- begin
- write(df,'</B>');
- end;
- procedure P20;
- var i : integer;
- begin
- for i := 1 to 10 do
- Write(df,'<p> </p>');
- end;
- procedure writefilename(filename : string);
- begin
- writeln(df,'<A HREF='+fnHolder.strings[i]+ '>' + Extractfilename(fnHolder.strings[i]) + '</A>');
- end;
- procedure writelink(display,link : string; wantreturn : boolean);
- begin
- write(df,'<A HREF=' + link + '>' + display + '</A>');
- if wantreturn then writeln(df);
- end;
- procedure writeanchor(name : string; wantreturn : boolean);
- begin
- Write(df,'<a name="' + name + '"></a>');
- if wantreturn then writeln(df);
- end;
- begin
- FnHolder := tstringlist.create();
- dummy := tstringlist.create();
- FnHolder.Sorted := true;
-
- assignfile(df,Indexfilename);
- Rewrite(df);
-
- for i := 0 to masks.count - 1 do
- begin
- dummy := pollfilelist(appendslash(path) + masks.strings[i],false);
- FnHolder.addstrings(dummy);
- end;
-
-
-
- AvaliableChars := '';
- For i := 0 to FnHolder.Count -1 do
- if Uppercase(LastChar) <> Uppercase(Extractfilename(FnHolder.Strings[i])[1]) then
- begin
- LastChar := Extractfilename(FnHolder.Strings[i])[1];
- AvaliableChars := AvaliableChars + Lastchar;
- end;
-
- AvaliableChars := Uppercase(AvaliableChars);
-
- Writeln(df,'<HTML><HEAD><TITLE>Index for ' + path + '</TITLE>');
-
-
- writeln(df,'<TABLE BORDER=2 cellpadding=1 cellspacing=1 width="95%">');
- TD; B;
- for i := 1 to length(AvaliableChars) do
- Writelink(AvaliableChars[i],'#' + AvaliableChars[i],true);
- EndB; EndTD;
-
- LastChar := ' ';
- for i := 0 to FnHolder.count -1 do
- begin
- if Uppercase(Extractfilename(FnHolder.Strings[i])[1]) <> Uppercase(Lastchar) then
- begin
- TR2;
- LastChar := Uppercase(Extractfilename(FnHolder.Strings[i]))[1];
- TD;
- Writeanchor(lastchar,false);
- B;
- Write(df,lastchar);
- EndB;
- EndTD; Writeln(df);
- end;
- TR;
- TD2;
- Writefilename(fnHolder.strings[i]);
- EndTD; Writeln(df);
- TD2;
- Write(df,SizeinK(Getfilesize(fnHolder.strings[i])));
- ENDTD; Writeln(df);
- TD2;
- Writelink('Contents >>',contentfilename + '#fn_' + inttostr(i),false);
- ENDTD; Writeln(df);
-
- end;
-
- writeln(df,'</TABLE>');
-
- writeln(df,'</HTML>');
- Closefile(df);
-
- assignfile(df,Contentfilename);
- Rewrite(df);
- for i := 0 to FnHolder.count -1 do
- if fileexists(FnHolder.strings[i]) then
- begin
- Set_Archive_List(fnHolder.strings[i]);
- List_Archive(0,0);
- WriteAnchor('fn_'+inttostr(i),true);
- Writefilename(fnHolder.strings[i]);
- writeln(df,'<TABLE BORDER=2 cellpadding=1 cellspacing=1 width="95%">');
- for j := 0 to Total_Contents - 1 do
- begin
- TR;
- TD2;
- Write(df,Archive_Contents[j]._Filename);
- ENDTD; Writeln(df);
- TD2;
- Write(df,Archive_Contents[j]._Filetype);
- ENDTD; Writeln(df);
- TD2;
- Write(df,SizeinK(Archive_Contents[j]._Filesize));
- ENDTD; Writeln(df);
- TD2;
-
- Write(df,' ' + Archive_Contents[j]._Filedefpath);
- ENDTD; Writeln(df);
- end;
- writeln(df,'</TABLE>');
- Writelink('Back to index',indexfilename,true);
- P20;
- end;
-
- writeln(df,'</HTML>');
- Closefile(df);
-
- dummy.free;
- FnHolder.free;
-
- end;
-
- procedure TCakdir.Thumbnail(Filename : string; cellHeight, cellWidth : Integer);
- var i : integer;
- tf : textfile;
- k : string;
- begin
- assignfile(tf,filename);
- rewrite(tf);
- Writeln(tf,'<HTML><HEAD><TITLE>Thumbnails </TITLE>');
- for i := 0 to Total_Contents - 1 do
- begin
- k := lowercase(Extractfileext(Archive_Contents[i]._filename));
- if (k = '.jpg') or (k = '.gif') or (k = '.png') then
- begin
- Write(tf,'<A HREF="'+ Archive_Contents[i]._filedefpath + Archive_Contents[i]._filename + '"');
- Write(tf,'><img src="'+ Archive_Contents[i]._filedefpath + Archive_Contents[i]._filename + '"');
- Write(tf,'width="' + inttostr(cellwidth)+ '" height="' + inttostr(cellheight) + '"></A>');
- Writeln(tf);
- end;
- end;
- Writeln(tf,'</HTML>');
- closefile(tf);
- end;
- procedure Register;
- begin
- RegisterComponents('QZip', [TCakDir]);
- end;
- end.
-
-
-
-