Creating a File List
Creating a File List
- public function __construct($paths) — Build a new FileList from an array of paths, e.g. from $argv.
Testing File Lists
Testing File Lists
A list of files, primarily useful for parsing command line arguments. This class makes it easier to deal with user-specified lists of files and directories used by command line tools.
$list = new FileList(array_slice($argv, 1)); foreach ($some_files as $file) { if ($list->contains($file)) { do_something_to_this($file); } }
This sort of construction will allow the user to type "src" in order to indicate 'all relevant files underneath "src/"'.
Build a new FileList from an array of paths, e.g. from $argv.
list | $paths | List of relative or absolute file paths. |
this | //Implicit.// |
Determine if a path is one of the paths in the list. Note that an empty file list is considered to contain every file.
string | $path | Relative or absolute system file path. |
bool | $allow_parent_directory | If true, consider the path to be contained in the list if the list contains a parent directory. If false, require that the path be part of the list explicitly. |
bool | If true, the file is in the list. |
Check if the file list is empty -- that is, it contains no files.
bool | If true, the list is empty. |