Return a file’s parent.


file.parent() File file.parent() null


cross bool (default false)

Cross filesystem boundaries. Getting the parent of an imported filesystem’s root file returns null, unless crossing is enabled, in which case it returns the parent on the importing filesystem. With crossing enabled, you will always get what you would expect by path.


Return a file’s direct ancestor. If no parent is accessible, eg. for the root file, null is returned.


Example when parent exists.

Example when no parent exists.

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.