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.

Currently you can only use links to import filesystems, which is not supported in this playground. Thus, it can not be demonstrated here.

For reference, here is how you would call follow by limiting the hops or filtering for specific link modes.