You are here

function PclZip::privAddList in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/lib/pclzip/pclzip.lib.php \PclZip::privAddList()
1 call to PclZip::privAddList()
PclZip::privCreate in includes/moodle/lib/pclzip/pclzip.lib.php

File

includes/moodle/lib/pclzip/pclzip.lib.php, line 2367

Class

PclZip

Code

function privAddList($p_filedescr_list, &$p_result_list, &$p_options) {

  //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list");
  $v_result = 1;

  // ----- Add the files
  $v_header_list = array();
  if (($v_result = $this
    ->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) {

    // ----- Return

    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    return $v_result;
  }

  // ----- Store the offset of the central dir
  $v_offset = @ftell($this->zip_fd);

  // ----- Create the Central Dir files header
  for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) {

    // ----- Create the file header
    if ($v_header_list[$i]['status'] == 'ok') {
      if (($v_result = $this
        ->privWriteCentralFileHeader($v_header_list[$i])) != 1) {

        // ----- Return

        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
        return $v_result;
      }
      $v_count++;
    }

    // ----- Transform the header to a 'usable' info
    $this
      ->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
  }

  // ----- Zip file comment
  $v_comment = '';
  if (isset($p_options[PCLZIP_OPT_COMMENT])) {
    $v_comment = $p_options[PCLZIP_OPT_COMMENT];
  }

  // ----- Calculate the size of the central header
  $v_size = @ftell($this->zip_fd) - $v_offset;

  // ----- Create the central dir footer
  if (($v_result = $this
    ->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) {

    // ----- Reset the file list
    unset($v_header_list);

    // ----- Return

    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
    return $v_result;
  }

  // ----- Return

  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
  return $v_result;
}