File.prototype.parents()

Return a file’s ancestors.

Syntax

file.parents() Collection file.parents(cross bool) Collection

Parameters

cross bool (default false)

Cross filesystem boundaries. Getting the parents from within an imported filesystem returns parents up to the imported root. With crossing enabled, all parents will be returned up to the highest file in the chain. With crossing enabled, you will always get what you would expect by path.

Description

Return a collection of a file’s ancestors in hierarchical order (deepest last).

Examples

Basic example.

When no parent exists an empty collection is returned.

Cross filesystem boundaries. Note that in this playground, we can not import remote filesystems, thus we can not show the difference here of using the cross argument.