function Archive_Tar::_addList

7.x system.tar.inc Archive_Tar::_addList($p_list, $p_add_dir, $p_remove_dir)
2 calls to Archive_Tar::_addList()
Archive_Tar::createModify in drupal-7.x/modules/system/system.tar.inc
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…
Archive_Tar::_append in drupal-7.x/modules/system/system.tar.inc

File

drupal-7.x/modules/system/system.tar.inc, line 896

Class

Archive_Tar
Creates a (compressed) Tar archive *

Code

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;
    }

    if (!file_exists($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;
}