WARNING: The [sjs-3] engine was deprecated, use [sjs-4] instead.

File.prototype.walk()

Walk a filesystem subtree.

Syntax

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)

Parameters

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.

Description

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.

Examples

Basic example.

Do not descend into the subtree of f1.

Find the file named f1, then stop walking immediately.