You are here

public function ArchiveTar::_addList in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Archiver/ArchiveTar.php \Drupal\Core\Archiver\ArchiveTar::_addList()

Parameters

array $p_list:

string $p_add_dir:

string $p_remove_dir:

Return value

bool

2 calls to ArchiveTar::_addList()
ArchiveTar::createModify in core/lib/Drupal/Core/Archiver/ArchiveTar.php
This method creates the archive file and add the files / directories that are listed in $p_filelist. If the file already exists and is writable, it is replaced by the new tar. It is a create and not an add. If the file exists and is read-only or is a…
ArchiveTar::_append in core/lib/Drupal/Core/Archiver/ArchiveTar.php

File

core/lib/Drupal/Core/Archiver/ArchiveTar.php, line 1172

Class

ArchiveTar

Namespace

Drupal\Core\Archiver

Code

public function _addList($p_list, $p_add_dir, $p_remove_dir) {
  $v_result = true;
  $v_header = array();

  // ----- Remove potential windows directory separator
  $p_add_dir = $this
    ->_translateWinPath($p_add_dir);
  $p_remove_dir = $this
    ->_translateWinPath($p_remove_dir, false);
  if (!$this->_file) {
    $this
      ->_error('Invalid file descriptor');
    return false;
  }
  if (sizeof($p_list) == 0) {
    return true;
  }
  foreach ($p_list as $v_filename) {
    if (!$v_result) {
      break;
    }

    // ----- Skip the current tar name
    if ($v_filename == $this->_tarname) {
      continue;
    }
    if ($v_filename == '') {
      continue;
    }

    // ----- ignore files and directories matching the ignore regular expression
    if ($this->_ignore_regexp && preg_match($this->_ignore_regexp, '/' . $v_filename)) {
      $this
        ->_warning("File '{$v_filename}' ignored");
      continue;
    }
    if (!file_exists($v_filename) && !is_link($v_filename)) {
      $this
        ->_warning("File '{$v_filename}' does not exist");
      continue;
    }

    // ----- Add the file or directory header
    if (!$this
      ->_addFile($v_filename, $v_header, $p_add_dir, $p_remove_dir)) {
      return false;
    }
    if (@is_dir($v_filename) && !@is_link($v_filename)) {
      if (!($p_hdir = opendir($v_filename))) {
        $this
          ->_warning("Directory '{$v_filename}' can not be read");
        continue;
      }
      while (false !== ($p_hitem = readdir($p_hdir))) {
        if ($p_hitem != '.' && $p_hitem != '..') {
          if ($v_filename != ".") {
            $p_temp_list[0] = $v_filename . '/' . $p_hitem;
          }
          else {
            $p_temp_list[0] = $p_hitem;
          }
          $v_result = $this
            ->_addList($p_temp_list, $p_add_dir, $p_remove_dir);
        }
      }
      unset($p_temp_list);
      unset($p_hdir);
      unset($p_hitem);
    }
  }
  return $v_result;
}