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

CompareFilenames

Compares two file names to see whether they are equal.

Declaration

Source position: fileutil.pas line 55

function CompareFilenames(

  Filename1: PChar;

  Len1: Integer;

  Filename2: PChar;

  Len2: Integer;

  ResolveLinks: Boolean

):Integer; overload;

Arguments

Filename1

  

First filename.

Len1

  

Length of first filename.

Filename2

  

Second filename.

Len2

  

Length of second filename.

ResolveLinks

  

When True, file system links are searched to find the actual file(s) for the comparison.

Function result

Returns zero (0) if files are equal, or when character values or file name lengths are not equal.

Description

CompareFileNames is an Integer function used to compare the specified file names (and lengths).

The Filename1 and Filename2 arguments are PChar types with pointers to the first character in each of the compared file names.The Len1 and Len2 arguments contain the length (or number of characters) for the pointers. If a length value is omitted, it implies the corresponding file name argument is empty.

ResolveLinks indicates whether file system or symbolic links are resolved before comparing the file name arguments. When set to True, the ComparePhysicalFilenames routine is called to resolve the file system links to actual path and file names for the comparison. For platforms where NotLiteralFilenames is defined, the file names are copied to a temporary string before resolving the file names.

Otherwise, the CompareFileNames routine (in LazFileUtils) is used to compare the file names and to get the return value.

The return value is 0 (zero) when the file names contain (or resolve to) the same files on the local file system. It is set to the difference between the lengths in Len1 and Len2 when one of the arguments has been omitted. For platforms where NotLiteralFilenames is not defined, it contains the initial difference between the ordinal values in the file names. Otherwise, it is set to the value from CompareFilenames (in LazFileUtils) or ComparePhysicalFilenames.

See also

ComparePhysicalFilenames

  

Compares file names after resolving symbolic links.

CompareFilenames

  

Gets the relative sort order for the specified file names.


Version 3.2 Generated 2024-02-25 Home