[Overview][Constants][Types][Procedures and functions][Variables][Index] Reference for unit 'LazFileUtils' (#lazutils)

ResolveDots

Resolves relative path references and removes duplicate path delimiters.

Declaration

Source position: lazfileutils.pas line 61

function ResolveDots(

  const AFilename: string

):string;

Arguments

AFilename

  

Qualified file name examined in the routine.

Function result

File name with relative paths expanded and duplicate delimiters removed.

Description

ResolveDots is a String function used to convert relative path information in AFilename to an absolute path reference. A relative path includes characters like '.' (for current directory - not a file name extension) and '..' (parent directory). Duplicate path limiters ('\\' for Windows) ('//' for UNIX-like environments) are converted to a single instance of the PathDelimiter defined for the platform.

For Windows platforms, drive letter designations and delimiters like 'C:' are recognized. A path starting with the UNC naming convention ('\\?\') is not resolved in the method.

Windows-specific file system quirks handled in the routine include:

C:..
Not resolved, it is copied.
C:\..
Resolved to C:\
\\..
Resolved to \\
c:/path/to/dir
Resolved to C:\path\to\dir using the PathDelimiter for the platform.

For UNIX-like environments, the resolved path may be invalid if it references the parent directory and the initial directory in the path is a symbolic link.

When AFilename ends with a relative path ('/.' or '/..'), the path is resolved to the directory represented by the relative value. The current directory for '/.' or the parent directory for '/..'.

If a relative path reference cannot be resolved for the local file system, the original path information is retained.

Some common examples include:

foo/bar/..
Resolved to foo
foo//..//
Resolved to .
foo/bar/./../baz
Resolved to foo/baz
/a/b/../..
Resolved to /
.//.//.
Resolved to .

Macros found in the AFilename are retained in the resolved file name. For example:

'($LazarusDir)/../path/that/may/be/invalid/for/macro/filename.ext'

If AFilename ends with a path trailing path delimiter or a relative path reference, the return value will end with a trailing path delimiter.


Version 3.2 Generated 2024-02-25 Home