Sign in Join
FPDoc Onlineexperiment

ForceDirectory function

In unit LazFileUtils

Creates the specified directory if it does not already exist.

Declaration

pascal
function ForceDirectory(DirectoryName: string): Boolean

Arguments

DirectoryName

Path information for the operation.

Function result

Returns True if directory exists or if it was successfully created.

Description

ForceDirectory is a Boolean function which creates the specified directory if it does not already exist. ForceDirectory ensures that a trailing path delimiter exists in DirectoryName prior to checking the file system. Duplicate adjacent path delimiters (like '//foo//bar/foobar/' or '\\foo\\bar\foobar\') are removed prior to checking the directory path.

Each directory in the specified path is validated by calling DirPathExists. ForceDirectory calls CreateDirUTF8 if a directory does not exist, and may exit with a return value of False if directory creation is not successful.

The return value is True if all directories in the path information already exist, or are successfully created in the function.

See also

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