class FileFinder (View source)

A utility class that finds any files matching a set of rules that are present within a directory tree.

Each file finder instance can have several options set on it:

  • name_regex (string): A regular expression that file basenames must match.
  • dir_regexp (string): A regular expression that dir basenames must match
  • accept_callback (callback): A callback that is called to accept a file. If it returns false the item will be skipped. The callback is passed the basename, pathname and depth.
  • accept_dir_callback (callback): The same as accept_callback, but only called for directories.
  • accept_file_callback (callback): The same as accept_callback, but only called for files.
  • file_callback (callback): A callback that is called when a file i succesfully matched. It is passed the basename, pathname and depth.
  • dir_callback (callback): The same as file_callback, but called for directories.
  • ignore_files (array): An array of file names to skip.
  • ignore_dirs (array): An array of directory names to skip.
  • ignore_vcs (bool): Skip over commonly used VCS dirs (svn, git, hg, bzr). This is enabled by default. The names of VCS directories to skip over are defined in {@link SS_FileFInder::$vcs_dirs}.
  • max_depth (int): The maxmium depth to traverse down the folder tree, default to unlimited.

Methods

__construct()

No description

mixed
getOption(string $name)

Returns an option value set on this instance.

setOption(string $name, mixed $value)

Set an option on this finder instance. See {@link SS_FileFinder} for the list of options available.

setOptions(array $options)

Sets several options at once.

array
find(string $base)

Finds all files matching the options within a directory. The search is performed depth first.

Details

__construct()

mixed getOption(string $name)

Returns an option value set on this instance.

Parameters

string $name

Return Value

mixed

setOption(string $name, mixed $value)

Set an option on this finder instance. See {@link SS_FileFinder} for the list of options available.

Parameters

string $name
mixed $value

setOptions(array $options)

Sets several options at once.

Parameters

array $options

array find(string $base)

Finds all files matching the options within a directory. The search is performed depth first.

Parameters

string $base

Return Value

array