Version 2 of fileutil::traverse

Updated 2013-07-30 15:17:34 by hv

hv From the documentation: *This package provides objects for the programmable traversal of directory hierarchies. *

While traversing down a directory, there are times when you encounter one that is not accessible. While the documentation stated that the package will ignore those directories by default. In reality, my sample script crashed. Curious, I dug into the source code and found what might be a bug. I posted the problem and a work-around solution on StackOverflow To sum up, I used the -prefilter option to determine if a directory is readble:

package require fileutil::traverse

proc isAccessible {absPath} {
    return [file readable $absPath]
}

# Main
set searchDir /tmp
fileutil::traverse t $searchDir -prefilter isAccessible

puts "\nFiles in $searchDir:"
t foreach fileName {
    puts $fileName
}