File.prototype.followLink()

Follow a file’s link and return the target file.

Syntax

file.followLink() File file.followLink() null file.followLink(maxHops int) File file.followLink(maxHops int) null file.followLink(maxHops int, followModes int) File file.followLink(maxHops int, followModes int) null

Parameters

maxHops int (default -1)

Limit the number of hops to make if there is a chain of links. By limiting the hops, you can get hold of any file in the link chain. You can also walk the link chain by always limiting the number of hops to 1.

followModes int (default -1)

Filter what link modes (link types) to follow. Use -1 to follow all link modes (to not filter what to follow). Use 0 to not follow anything. See link modes for more details.

Description

Follow a file’s link and return the target file. You may limit what link modes to follow and after how many hops to stop. Following empty links is a no-operation, will return the file itself. Note that the link may be broken.

Examples

Example when no link is set up.

A path link references an other file by path. The only purpose of a path links is that it can be followed. It does NOT affect the children or the data stored in the file itself. It is not automatically followed.

Limit the number of hops.