ad_find_all_files (public)

 ad_find_all_files [ -include_dirs include_dirs ] \
    [ -include_bak_dirs include_bak_dirs ] [ -max_depth max_depth ] \
    [ -check_file_func check_file_func ] path

Defined in packages/acs-bootstrap-installer/tcl/10-utilities-procs.tcl

Returns a list of full paths to all files under $path in the directory tree (descending the tree to a depth of up to $max_depth). Clients should not depend on the order of files returned. Per default, the contents of .bak directories (as produced e.g. via "install from repository" are not included. To include these, add the flag "-include_bak_dirs 1" to the invocation.

Switches:
-include_dirs (optional, defaults to "0")
-include_bak_dirs (optional, defaults to "0")
-max_depth (optional, defaults to "10")
-check_file_func (optional)
Parameters:
path (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_files__tcl_file_common_errors files__tcl_file_common_errors (test acs-tcl) ad_find_all_files ad_find_all_files test_files__tcl_file_common_errors->ad_find_all_files test_get_package_files get_package_files (test acs-bootstrap-installer) test_get_package_files->ad_find_all_files apm_get_package_files apm_get_package_files (public) apm_get_package_files->ad_find_all_files apm_get_watchable_files apm_get_watchable_files (private) apm_get_watchable_files->ad_find_all_files apm_load_queries apm_load_queries (private) apm_load_queries->ad_find_all_files packages/acs-admin/www/apm/version-i18n.tcl packages/acs-admin/ www/apm/version-i18n.tcl packages/acs-admin/www/apm/version-i18n.tcl->ad_find_all_files packages/file-storage/www/folder-add.tcl packages/file-storage/ www/folder-add.tcl packages/file-storage/www/folder-add.tcl->ad_find_all_files

Testcases:
get_package_files, files__tcl_file_common_errors
Source code:
    # Use the examined_files array to track files that we've examined.
    array set examined_files [list]

    # A list of files that we will return (in the order in which we
    # examined them).
    set files [list]

    # A list of files that we still need to examine.
    set files_to_examine [list $path]

    # Perform a breadth-first search of the file tree. For each level,
    # examine files in $files_to_examine; if we encounter any directories,
    # add contained files to $new_files_to_examine (which will become
    # $files_to_examine in the next iteration).
    while { [incr max_depth -1] > 0 && [llength $files_to_examine] != 0 } {
        set new_files_to_examine [list]
        foreach file $files_to_examine {
            # Only examine the file if we haven't already. (This is just a safeguard
            # in case, e.g., Tcl decides to play funny games with symbolic links so
            # we end up encountering the same file twice.)
            if { ![info exists examined_files($file)] } {
                # Remember that we've examined the file.
                set examined_files($file) 1

                if { $check_file_func eq "" || [$check_file_func $file] } {
                    # If it's a file, add to our list. If it's a
                    # directory, add its contents to our list of files to
                    # examine next time.
                    if { [file isfile $file] } {
                        lappend files $file
                    } elseif { [file isdirectory $file] } {
                        if { $include_bak_dirs && [string match "*.bak" $file] } {
                            continue
                        }
                        if { $include_dirs == 1 } {
                            lappend files $file
                        }
                        if {[catch {lappend new_files_to_examine {*}[glob -nocomplain "$file/*"]} errorMsg]} {
                            ns_log warning "ad_find_all_files: $errorMsg"
                        }
                    }
                }
            }
        }
        set files_to_examine $new_files_to_examine
    }
    return $files
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: