/**
* Returns a Finder instance for the files that will be included in the
* backup.
*
* By default we ignore unreadable files and directories as well as, common
* version control folders / files, "Dot" files and anything matching the
* exclude rules.
*
* @uses Finder
* @return Finder The Finder iterator of all files to be included
*/
public function get_files()
{
$finder = new Finder();
$finder->followLinks(true);
$finder->ignoreDotFiles(false);
$finder->ignoreVCS(true);
$finder->ignoreUnreadableDirs(true);
// Skip unreadable files too
$finder->filter(function (\SplFileInfo $file) {
if (!$file->isReadable()) {
return false;
}
});
// Finder expects exclude rules to be in a regex format
$exclude_rules = $this->excludes->get_excludes_for_regex();
// Skips folders/files that match default exclude patterns
foreach ($exclude_rules as $exclude) {
$finder->notPath($exclude);
}
return $finder->in(Path::get_root());
}