Skip to content

Modern Fs DirEntry ContentsFirst

Paul Squires edited this page Oct 19, 2026 · 2 revisions

Home › Filesystem › Filesystem Library › WalkOptions.ContentsFirst

WalkOptions.ContentsFirst

Chooses whether a walk returns each folder after its contents; false by default.

Syntax

WalkOptions.ContentsFirst

Notes

  • FALSE by default (pre-order: a directory before what is in it). TRUE yields each directory AFTER its contents -- the order a recursive delete needs.
  • The root of the walk is never yielded, in either order.

Examples

#import "std/fs"
using fs

dim as ustring dir_ = CreateTempDir( "tkdoc" ).Value( )
CreateDirAll( PathJoin( dir_, "src" ) )
CreateDirAll( PathJoin( dir_, "build" ) )
WriteAllText( PathJoin( dir_, "src", "main.tiko" ), "x" )
WriteAllText( PathJoin( dir_, "build", "main.o" ), "x" )
WriteAllText( PathJoin( dir_, "README" ), "x" )
dim as WalkOptions o
o.ContentsFirst = true
o.SortByName = true
for each e in WalkDir( dir_, o )
    print e.Value( ).Name( )
next
'' README  main.o  build  main.tiko  src
RemoveDirAll( dir_ )

Library: Filesystem Library Category: Filesystem Documented under: Directories

Clone this wiki locally