Walk a filesystem subtree.


file.walk(callback function(fi File)) file.walk(callback function(fi File), followImportLinks Boolean) file.walk(callback function(fi File) (walkDirection int)) file.walk(callback function(fi File) (walkDirection int), followImportLinks Boolean)


callback function(fi File)

The function to be executed on each file.

callback function(fi File) (walkDirection int)

The function to be executed on each file. The return value walkDirection shall be one of the following:

  • 1 to descend into the subtree,
  • 0 to NOT descend into the subtree of fi,
  • -1 to stop walking alltogether, in which case .walk() will return immediately.
followImportLinks Boolean

By default, walk does not descend into imported subtrees. Pass in true to enable descending.


Walk a filesystem subtree. Import links are not followed by default, but can be followed optionally.

The callback function is first called on the file itself.


Basic example.

Do not descend into the subtree of f1.

Find the file named f1, then stop walking immediately.