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

CreateRelativePath

Creates a relative path from BaseDirectory to Filename

Declaration

Source position: lazfileutils.pas line 68

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 '.'. Duplicate path delimiters are removed. For example, the following is True:

TrimFilename(Filename) = TrimFilename(BaseDirectory+PathDelim+Result).
          
The latest version of this document can be found at lazarus-ccr.sourceforge.net.