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

ReadAllLinks

Resolves a symbolic link to an actual file name.

Declaration

Source position: lazfileutils.pas line 137

function ReadAllLinks(

  const Filename: string;

  ExceptionOnError: Boolean

):string;

Arguments

Filename

  

Symbolic link resolved in the routine.

ExceptionOnError

  

True to raise an exception for unresolved or broken links. False to handle the error internally without raising an exception.

Function result

Resolved path to the specified file name, or an exception message when link(s) could not be resolved.

Description

ReadAllLinks is a String function used to resolve a symbolic link to an actual file name. The implementation is platform-specific.

For UNIX-like platforms, fpReadLink (RTL) is used to recursively follow symbolic links starting at FileName (to a maximum depth of 12) until it is resolved to a path on the local file system. No actions are performed in the routine if FileName is a regular file and not a symbolic link.

The return value contains the resolved path to the file on the local file system. This includes calling ResolveDots for a file name with a relative path. If the return value is empty when an error is detected, the error message is captured and used in an EFOpenError exception raised when ExceptionOnError is enabled. If ExceptionOnError is False, the function returns an empty string ('') for an invalid link.

For the Windows platform, FileGetSymLinkTarget (RTL) is recursively called (to a maximum depth of 20) to get the reparse point with the target file name. The return value contains the UTF-8-encoded path to the file on the local file system, or an empty string if FileName is not a valid symbolic link. ExceptionOnError indicates whether an EFOpenError exception is raised for an invalid link in FileName. If ExceptionOnError is False, the function returns an empty string ('') and the exception is not raised for an invalid link.

For the Amiga platform, the return value is always an empty string ('').

Version info

Modified in LazUtils version 3.6 to implement the routine on the Windows platform.


Version 4.0 Generated 2025-05-03 Home