Sign in Join
FPDoc Onlineexperiment

CopyDirTree function

In unit FileUtil

Copies all file system entries in a source directory to the destination directory using the specified options.

Declaration

pascal
function CopyDirTree(const SourceDir: string; const TargetDir: string; 
 Flags: TCopyFileFlags=[]; 
 CopyEmptyDirs: Boolean=False): Boolean

Arguments

SourceDir

Directory with the files copied in the routine.

TargetDir

Directory where the copied files are stored.

Flags

Options enabled for the copy operation; default value is an empty set ([])

CopyEmptyDirs

Indicates whether directories which contain no files are processed in the copy operation. Default value is False.

Function result

True when all files are successfully copied in the routine.

Description

CopyDirTree is a Boolean function used to copy file system entries from the directory in SourceDir to the directory in TargetDir.

Values in SourceDir and TargetDir are fully-qualified path names for the directories. If a trailing path delimiter is omitted in SourceDir or TargetDir, it is appended (when needed) to the values. TargetDir cannot be a sub-directory located in SourceDir. No actions are performed in the routine when TargetDir is located within the specified SourceDir.

Flags contains values representing the options enabled in the copy operation. The default value for the parameters is an empty set ( []) and indicates that none of the TCopyFileFlag options are enabled. The value cffCreateDestDirectory is always added to the values in Flags internally; CopyDirTree requires the destination directory to be created if it does not already exist.

See TCopyFileFlag for more information about the option values and their meanings.

CopyEmptyDirs indicates whether an empty directory found in the routine is automatically created in the destination directory. The default value is False and prevents an empty directory in SourceDir from being copied to DestDir. When set to True, the empty directory will be created in DestDir.

The return value is True when all file system entries in SourceDir are successfully copied in the routine. Please note that a portion of the copy operation may have been performed successfully even when the return value is False.

Use CopyFile to copy a single file with a given name to a new file name.

Modified in LazUtils version 5.0 to incorporate the CopyEmptyDirs argument.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.