Get database restoration files.

@param string $path

@throws BackupException

@return array
163492
public function getRestorationFiles($path = null)
	{
		if ($path === null) {
			$path = $this->getPath();
		}

		$results = [];

		if (!$this->getBackupFilesystemInstance()->checkPathExists($path)) {
			throw new BackupException('Unable to get restoration files as path "' . $path . '" doesn\'t exist');
		}

		try {
			foreach (new DirectoryIterator($path) as $fileinfo) {
				if ($fileinfo->isDot() ||
					!$fileinfo->isFile() ||
					in_array($fileinfo->getFilename(), BackupFilesystem::$ignoredFiles) ||
					substr($fileinfo->getFilename(), 0, 1) == '.'
				) {
					continue;
				}

				$results[] = $fileinfo->getPathname();
			}
		} catch (Exception $exception) {
			// Exception thrown continue and return empty result set
		}

		return $results;
	}
911803
public function getEntities($path)
    {
        $entities = [];

        $Directory = new \RecursiveDirectoryIterator($path);
        $Iterator = new \RecursiveIteratorIterator($Directory);
        $objects = new \RegexIterator($Iterator, '/.*(.php)$/', \RecursiveRegexIterator::GET_MATCH);

        foreach ($objects as $filename => $object) {
            $file = explode('/', $filename);
            if (!preg_filter($this->ignoredFolder, [], $file)) {
                $classname = $this->getNamespace($filename) . NAMESPACE_SEPARATOR . substr(basename($filename), 0, -4);
                if ($this->isValidNamespace($classname)) {
                    $entities[] = $classname;
                }
            }
        }

        return $entities;
    }
1148879
protected function getFileInfo($path)
    {
        return [
            'name' => substr($path, strrpos($path, '/') + 1),
            'path' => $path,
            'url'  => $this->getFileUrl($path),
        ];
    }
1210472
public function getListDbConn($path = null) {
		if (empty($path)) {
			$path = APP;
		}

		$configFile = $path . 'Config' . DS . 'database.php';
		$connections = [];
		if (file_exists($configFile)) {
			$connections = array_keys(ConnectionManager::enumConnectionObjects());
		}

		return $connections;
	}
73431
protected function getPhpFiles($path)
    {
        if (is_dir($path)) {
            return new RegexIterator(
                new RecursiveIteratorIterator(
                    new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
                    RecursiveIteratorIterator::SELF_FIRST,
                    RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
                ),
                '/^.+\.php$/i',
                RecursiveRegexIterator::GET_MATCH
            );
        }
        else {
            return [];
        }
    }
494418
private function lsdir(string $path): array
    {
        $result = @scandir($path);

        if (false === $result) {
            $message = 'Could not read directory.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return array_values(array_diff($result, ['.', '..']));
    }
489926
private function getFiles($path)
    {
        $files = array();

        foreach (new \DirectoryIterator($path) as $file) {
            if ($file->isDot()
                || (null != $this->scriptName && sprintf('%s.php', $this->scriptName) != $file->getFilename())
            ) {
                continue;
            }

            $files[$file->getFilename()] = sprintf('%s/%s', $file->getPath(), $file->getFilename());
        }
        sort($files);

        return $files;
    }
1001597
protected function restoreFile($filePath, $backupPath, $clean = true)
    {
        if (file_exists($backupPath)) {
            copy($backupPath, $filePath);

            if ($clean) {
                unlink($backupPath);
            }
        }

        return $backupPath;
    }
120031
public function rmdir($path)
    {
        self::restore();
        $path = self::overlayPath($path);
        $success = rmdir($path);
        self::register();
        return $success;
    }
190881
protected function fileDetails($path)
    {
        $path = '/'.ltrim($path, '/');

        return [
            'name'         => basename($path),
            'fullPath'     => $path,
            'webPath'      => $this->fileWebpath($path),
            'mimeType'     => $this->fileMimeType($path),
            'size'         => $this->fileSize($path),
            'modified'     => $this->fileModified($path),
            'relativePath' => $this->fileRelativePath($path),
        ];
    }
722407
private function getContents(string $path)
    {
        set_error_handler(static function ($type, $msg) use (&$error): void {
            $error = $msg;
        });
        $content = file_get_contents($path);
        restore_error_handler();
        if (false === $content) {
            throw new \RuntimeException($error);
        }

        return $content;
    }
1041917
public function fileDetails($path)
    {
        $path = '/'.ltrim($path, '/');

        return [
            'name'     => basename($path),
            'fullPath' => $path,
            'webPath'  => $this->fileWebPath($path),
            'mimeType' => $this->fileMimeType($path),
            'size'     => $this->fileSize($path),
        ];
    }
876172
public function listFiles($path = '')
    {
        $directory = $this->getPath($path);
        if (!is_dir($directory)) {
            throw new RuntimeException(
                $directory . ' is not a directory.'
            );
        }

        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator(
                $this->getPath($path),
                RecursiveDirectoryIterator::SKIP_DOTS
            ),
            RecursiveIteratorIterator::SELF_FIRST
        );

        $files = [];

        /** @var SplFileInfo $fileInfo */
        foreach ($iterator as $fileInfo) {
            if ($fileInfo->isDir()) {
                continue;
            }

            $files[] = preg_replace(
                sprintf('/^%s/', preg_quote($this->root, '/')),
                '',
                $fileInfo->getPathname()
            );
        }

        return $files;
    }
1247236
public function getMigrationFiles($path)
    {
        $files = Helpers::rGlob($path.'/*_*.php');

        if ($files === false) {
            return [];
        }

        $files = array_map(function ($file) {
            return str_replace('.php', '', basename($file));

        }, $files);

        sort($files);

        return $files;
    }
58031
protected function getPath($path)
	{
		$paths = array();

		// If `$path` is an array
		if (is_array($path))
		{
			foreach ($path as $unverifiedPath)
			{
				$paths = array_merge($paths, $this->getPath($unverifiedPath));
			}

			return $paths;
		}

		// If `$path` is a directory
		if (is_dir($path))
		{
			$paths = glob($path . '/*.*');

			return $paths;
		}

		// If `$path` is a file
		if (file_exists($path))
		{
			$paths[] = $path;
		}

		return $paths;
	}
244268
private function getFiles($path)
    {
        $files = [];

        if (false !== $pos = strpos($path, '*')) {
            list($before, $after) = explode('*', $path, 2);
            $input = $this->fileLocator->locate($before).'*'.$after;

            if (false !== $paths = glob($input)) {
                foreach ($paths as $path) {
                    $files[] = $path;
                }
            }
        } else {
            $files = [$this->fileLocator->locate($path)];
        }

        return $files;
    }
1063239
public static function getFileList(string $path, array $exts = null) : array
    {
        $files = [];
        if (is_dir($path) && ($dh = opendir($path))) {
            while (($file = readdir($dh)) !== false) {
                if ($file === '.' || $file === '..' || $file === '.DS_Store') {
                    continue;
                } elseif (is_dir("{$path}/{$file}")) {
                    $files = array_merge($files, self::getFileList("{$path}/{$file}", $exts));
                } elseif (is_null($exts)) {
                    $files[] = "{$path}/{$file}";
                } elseif (in_array(pathinfo("{$path}/{$file}", PATHINFO_EXTENSION), $exts)) {
                    $files[] = "{$path}/{$file}";
                } else {
                    continue;
                }
            }
            closedir($dh);
        }
        return $files;
    }