Class TCustomCopyFile (unit LNCopyFile)

Inherits from

TComponent

Constructors


constructor Create(AOWner: TComponent);



Functions

function AppendSlash(const sDir : String): String;


function CopyDirectory( const from_dir, to_dir : String ) : Boolean;


procedure CopyFiles( AList : TStrings; const DestDirectory : String );


procedure CopyFilesWithJoker( const FileName, DestDirectory : String );

Copy subdirectory

procedure CopyNow;

MUST BE IN EVERY COMPONENT

function DeleteDirectory( const dir : String ) : Boolean;

Add file

destructor Destroy;

MUST BE IN EVERY COMPONENT

function DiskInDrive(Drive: Char): Boolean;


function FindFile( const FileName, DirectoryStart : String ) : Boolean;

Check if the file is locked

procedure Finish;

Start copy of multiple files, so we'll create the Progress form only once

function GetDirectoryCount( const dir : String ) : Integer;

Add file

function GetDirectorySize( const dir : String ) : Integer;

Copy file

function IsDirectoryEmpty( const dir : String ) : Boolean;

Delete the empty directory

function IsDirectoryInUse( const dir : String ) : Boolean;

This function checks if a Directory is in use.

function RemoveSlash(const sDir : String): String;


procedure SetCaption( const str : String );


procedure SetProgress( progress : Integer );


procedure Start;

Main procedure

Above line was suggested by Russel Havens, USA.


procedure WriteFileName( const filename : String );

Finish the copy of multiple files, so we'll destroy the Progress form

function GetIsWorking : Boolean;


procedure PrecalcDirSize( const dir : String );

MSDos filter

Properties

property CancelOperation : Boolean


property Caption : String


property CopyFrom : string

Below is the properties as created in the component

property CopyTo : string


property Filter : String


property IsWorking : Boolean


property Movefile : Boolean


property Processed : Longint


property Progress : Boolean


property ProgressKind : TProgressKind


property Recursive : Boolean


property SendEvents : Boolean


property ShowFileNames : Boolean


property TransferFileAttributes : Boolean


property TransferTimeDate : Boolean


Events

event OnEachFile : TEachFileEvent


event OnFinishOperation : TNotifyEvent


event OnNotExists : String


event OnOperationProgress : TOperationProgressEvent


event OnStartOperation : TNotifyEvent


Variables

FBytesCopied : Integer;

Total of bytes to copy

FBytesToCopy : Integer;


FCancelOperation : Boolean;


FCaption : String;

File names if true and FShowProgress is true

FCopyFrom : String;

Protected declarations

FCopyMultipleFiles : Boolean;


FCopyTo : String;

Source file

FFilter : String;

Total of bytes already copied

FMoveFile : Boolean;

Caption on the progress bar form

FOnEachFile : TEachFileEvent;


FOnFinishOperation : TNotifyEvent;


FOnNotExists : String;

How much is processed is stored here (in percent 1% to 100%).

FOnOperationProgress : TOperationProgressEvent;


FOnStartOperation : TNotifyEvent;

Number of call of the Start/Finish methods

FProcessed : Longint;

If True the progress bar is shown

FProgressForm : TProgform;


FProgressKind : TProgressKind;

Set it to True if you want to cancel the current operation

FRecursive : Boolean;


FSendEvents : Boolean;


FShowFileNames : Boolean;

Errormessage if the file do not exists

FShowProgress : Boolean;

Target file

FStartCount : Integer;

Transfers the file time and date if true

FTransferFileAttributes : Boolean;


FTransferTimeDate : Boolean;

Moves the file if true


Constructors


constructor Create(AOWner: TComponent);


Functions


function AppendSlash(const sDir : String): String;


function CopyDirectory( const from_dir, to_dir : String ) : Boolean;


procedure CopyFiles( AList : TStrings; const DestDirectory : String );


procedure CopyFilesWithJoker( const FileName, DestDirectory : String );

Copy subdirectory


procedure CopyNow;

MUST BE IN EVERY COMPONENT


function DeleteDirectory( const dir : String ) : Boolean;

Add file


destructor Destroy;

MUST BE IN EVERY COMPONENT


function DiskInDrive(Drive: Char): Boolean;


function FindFile( const FileName, DirectoryStart : String ) : Boolean;

Check if the file is locked


procedure Finish;

Start copy of multiple files, so we'll create the Progress form only once


function GetDirectoryCount( const dir : String ) : Integer;

Add file


function GetDirectorySize( const dir : String ) : Integer;

Copy file


function IsDirectoryEmpty( const dir : String ) : Boolean;

Delete the empty directory


function IsDirectoryInUse( const dir : String ) : Boolean;

This function checks if a Directory is in use. It travels each subdirectory and tries to open each file in exclusive mode. If it fails, it means that someone has already locked this file, and it won't be possible to delete the directory containing it.


function RemoveSlash(const sDir : String): String;


procedure SetCaption( const str : String );


procedure SetProgress( progress : Integer );


procedure Start;

Main procedure

Above line was suggested by Russel Havens, USA.


procedure WriteFileName( const filename : String );

Finish the copy of multiple files, so we'll destroy the Progress form


function GetIsWorking : Boolean;


procedure PrecalcDirSize( const dir : String );

MSDos filter


Properties


property CancelOperation : Boolean


property Caption : String


property CopyFrom : string

Below is the properties as created in the component


property CopyTo : string


property Filter : String


property IsWorking : Boolean


property Movefile : Boolean


property Processed : Longint


property Progress : Boolean


property ProgressKind : TProgressKind


property Recursive : Boolean


property SendEvents : Boolean


property ShowFileNames : Boolean


property TransferFileAttributes : Boolean


property TransferTimeDate : Boolean


Events


event OnEachFile : TEachFileEvent


event OnFinishOperation : TNotifyEvent


event OnNotExists : String


event OnOperationProgress : TOperationProgressEvent


event OnStartOperation : TNotifyEvent


Variables


FBytesCopied : Integer;

Total of bytes to copy


FBytesToCopy : Integer;


FCancelOperation : Boolean;


FCaption : String;

File names if true and FShowProgress is true


FCopyFrom : String;

Protected declarations


FCopyMultipleFiles : Boolean;


FCopyTo : String;

Source file


FFilter : String;

Total of bytes already copied


FMoveFile : Boolean;

Caption on the progress bar form


FOnEachFile : TEachFileEvent;


FOnFinishOperation : TNotifyEvent;


FOnNotExists : String;

How much is processed is stored here (in percent 1% to 100%). This is mostly for the user which want to make his own progress bar


FOnOperationProgress : TOperationProgressEvent;


FOnStartOperation : TNotifyEvent;

Number of call of the Start/Finish methods


FProcessed : Longint;

If True the progress bar is shown


FProgressForm : TProgform;


FProgressKind : TProgressKind;

Set it to True if you want to cancel the current operation


FRecursive : Boolean;


FSendEvents : Boolean;


FShowFileNames : Boolean;

Errormessage if the file do not exists


FShowProgress : Boolean;

Target file


FStartCount : Integer;

Transfers the file time and date if true


FTransferFileAttributes : Boolean;


FTransferTimeDate : Boolean;

Moves the file if true