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

CreateRelativePath

Gets the relative path from BaseDirectory to Filename.

Declaration

Source position: lazfileutils.pas line 69

function CreateRelativePath(

  const Filename: string;

  const BaseDirectory: string;

  UsePointDirectory: Boolean = False;

  AlwaysRequireSharedBaseFolder: Boolean = True

):string;

Arguments

Filename

  

File name for the operation.

BaseDirectory

  

Base directory for the relative path.

UsePointDirectory

  

True if '.' (current directory symbol) is prepended to the relative path.

Function result

Relative path from the base directory for the file name.

Description

CreateRelativePath is a String function used to get the relative path from BaseDirectory to Filename. A trailing path delimiter in BaseDirectory is ignored. If there is no relative path, the value in Filename is returned.

When BaseDirectory and Filename contain the same value, and UsePointDirectory is False, an empty string ('') is used as the return value. If UsePointDirectory contains True, the return value is the '.' character. Duplicate path delimiters are removed.

Remark: CreateRelativePath is thread safe, and therefore, does not guarantee that the current directory is correct for file names like 'D:test.txt'.

See also

TryCreateRelativePath

  

Attempts to create a path in Dest relative to the path in Source.


Version 3.2 Generated 2024-02-25 Home