You are here

function acquia_migrate_files_to_backup in Acquia Connector 6.2

Same name and namespace in other branches
  1. 7.2 acquia_agent/acquia_agent.migrate.inc \acquia_migrate_files_to_backup()

Recursive function to find files to archive.

1 call to acquia_migrate_files_to_backup()
_acquia_migrate_archive_site in acquia_agent/acquia_agent.migrate.inc

File

acquia_agent/acquia_agent.migrate.inc, line 544
Upload to Acquia Cloud.

Code

function acquia_migrate_files_to_backup($directory, $exclude) {
  $array_items = array();
  if ($handle = opendir($directory)) {
    while (FALSE !== ($file = readdir($handle))) {
      if (!is_link($file) && !in_array($file, $exclude) && !in_array($directory . DIRECTORY_SEPARATOR . $file, $exclude)) {
        if (is_dir($directory . DIRECTORY_SEPARATOR . $file)) {

          // Do not include directories that cannot be executed to prevent
          // Archive_Tar error.
          if (@file_exists($directory . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . '.')) {
            $array_items = array_merge($array_items, acquia_migrate_files_to_backup($directory . DIRECTORY_SEPARATOR . $file, $exclude));
          }
        }
        elseif (is_readable($directory . DIRECTORY_SEPARATOR . $file)) {
          $file = $directory . DIRECTORY_SEPARATOR . $file;
          $array_items[] = preg_replace("/\\/\\//si", DIRECTORY_SEPARATOR, $file);
        }
      }
    }
    closedir($handle);
  }
  return $array_items;
}