Unit Backup

Designer: Craig Ward, 100554.2072@compuserve.com Date: 5/2/96 Version: 3.57 Function: Backup dialog DLL. Copies files from a source to a target. Will copy the contents of a directory, or, a single file. An additional call will uncompress the target file if the source was compressed using MS's COMPRESS.EXE Update: The following enhancements have been made since the previous version: [1] an additional facility enables users to copy only newer files (this is achieved by checking file dates, and only copying those which are newer) [2] as a consequence to the above I've had to make a change to the DLL call "HideBackupDlg". A new parameter (a bool) accomodates this feature. [3] there was a bug which misreported file size\date info when overwriting (it was in fact reported the wrong way round!) Space: The way that the DLL works in checking size\space is the following: [1] it sums the size of the files to be copied [2] it sums the size of the existing target files [3] it finds the size of the target disk, if less than the size of the files being copied it aborts [4] if the size of the target disk is okay, the next thing to check is the free space on the target drive. The DLL finds this figure, and adds to it the size of the existing target files (ie: it's expecting the user will overwrite these). Again, if this figure is smaller than that being copied it aborts. [5] During the actual copying process the DLL will again check the free space on the target drive (handy for users of the CopyIndivFile call). (users of RAM drives beware: when the DLL checks file size, it doesn't bother to check the maximum number of file entries allowed) Calls: procedure ShowBackupDlg(pSource,pDestination,pHelp,pCompat: pChar; bOverwritePrompt: boolean); - opens the dialog box. This proc copies the contents of a whole directory that conforms to the mask passed over. procedure HideBackupDlg(pSource,pDestination,pHelp,pCompat: pChar; bOverwritePrompt, bCopyNew: boolean); - loads, but does not open dialog box, and executes the backup automatically, then closes. This proc copies the contents of a whole directory that conforms to the mask passed over. procedure CopyIndivFile(pSourceFile,pDestinationFile: pChar); - copies the source file to the target file. procedure ExpandIndivFile(pSourceFile,pDestinationFile: pChar); - copies the source file to the target file, and expands the file if it was compressed (using MS-COMPRESS.EXE). Extra: Big thankyou to Dennis Passmore (71640.2464@compuserve.com), for his additions to the unit. These consisted of expanded error checking, creation of a custom type (the large buffer) to speed up the whole process and reduce stack usage, plus, the neat trick of restoring the file-date of the backed-up files to reflect the date of the source file, as opposed to that of when they were backed up. Also, a thankyou to Gregory Kraft (72114.3111@compuserve.com) who's enquiry precipitated the addition of the HideBackupDlg procedure. And, another thank you goes to Shane Mulo (INTERNET:mulo@peg.apc.org) for his kind words and ideas for improvement. Finally, I'd like to thank Philip Kapusta (74170.3550@compuserve.com) for his diligence and patience in putting the DLL to test. His criticisms have helped shape the whole utility. All criticisms, help and general advice are greatly welcomed.

Classes

TBackupDlg -

Functions

CopyIndivFile - *Exported Procedures*********************************************************} {calls the dialog - invisible - and copies the file
ExpandIndivFile - calls the dialog - invisible - and copies the file, expanding it if compressed
HideBackupDlg - calls the dialog - invisible and runs backup automatically
ShowBackupDlg - help-context for SelectDirectory Dialog} {exported procedures

calls the dialog - visible

Types

TFileInfo

Constants

iHelp

Variables

BackupDlg
iErrorMode
OkToAll


Functions


procedure CopyIndivFile(pSourceFile,pDestinationFile: pChar);

*Exported Procedures*********************************************************} {calls the dialog - invisible - and copies the file

procedure ExpandIndivFile(pSourceFile,pDestinationFile: pChar);

calls the dialog - invisible - and copies the file, expanding it if compressed

procedure HideBackupDlg(pSource,pDestination,pHelp,pCompat: pChar; bOverwritePrompt, bCopyNew: boolean);

calls the dialog - invisible and runs backup automatically

procedure ShowBackupDlg(pSource,pDestination,pHelp,pCompat: pChar; bOverwritePrompt: boolean);

help-context for SelectDirectory Dialog} {exported procedures

calls the dialog - visible


Types


TFileInfo = record
Date : longint;
Size : longint;
end;
custom type to hold file information

Constants

iHelp = 105


Variables

BackupDlg : TBackupDlg

iErrorMode : word

OkToAll : boolean