You are here

protected function DirectoryDestination::_getAllFileNames in Backup and Migrate 8.4

Get the entire file list from this destination.

Return value

array

2 calls to DirectoryDestination::_getAllFileNames()
DirectoryDestination::countFiles in lib/backup_migrate_core/src/Destination/DirectoryDestination.php
DirectoryDestination::listFiles in lib/backup_migrate_core/src/Destination/DirectoryDestination.php
Return a list of files from the destination. This list should be date ordered from newest to oldest.

File

lib/backup_migrate_core/src/Destination/DirectoryDestination.php, line 240

Class

DirectoryDestination
Class ServerDirectoryDestination.

Namespace

BackupMigrate\Core\Destination

Code

protected function _getAllFileNames() {
  $files = [];

  // Read the list of files from the directory.
  $dir = $this
    ->confGet('directory');

  /** @var \Drupal\Core\File\FileSystemInterface $fileSystem */
  $fileSystem = \Drupal::service('file_system');
  $scheme = $fileSystem
    ->uriScheme($dir);

  // Ensure the stream is configured.
  if (!$fileSystem
    ->validScheme($scheme)) {
    drupal_set_message(t('Your @scheme stream is not configured.', [
      '@scheme' => $scheme . '://',
    ]), 'warning');
    return $files;
  }
  if ($handle = opendir($dir)) {
    while (FALSE !== ($file = readdir($handle))) {
      $filepath = $dir . '/' . $file;

      // Don't show hidden, unreadable or metadata files.
      if (substr($file, 0, 1) !== '.' && is_readable($filepath) && substr($file, strlen($file) - 5) !== '.info') {
        $files[] = $file;
      }
    }
  }
  return $files;
}