You are here

function PclZip::privList in Quiz 6.5

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

File

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

Class

PclZip

Code

function privList(&$p_list) {

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

  // ----- Magic quotes trick
  $this
    ->privDisableMagicQuotes();

  // ----- Open the zip file

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
  if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) {

    // ----- Magic quotes trick
    $this
      ->privSwapBackMagicQuotes();

    // ----- Error log
    PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in binary read mode');

    // ----- Return

    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    return PclZip::errorCode();
  }

  // ----- Read the central directory informations
  $v_central_dir = array();
  if (($v_result = $this
    ->privReadEndCentralDir($v_central_dir)) != 1) {
    $this
      ->privSwapBackMagicQuotes();

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

  // ----- Go to beginning of Central Dir

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
  @rewind($this->zip_fd);

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
  if (@fseek($this->zip_fd, $v_central_dir['offset'])) {
    $this
      ->privSwapBackMagicQuotes();

    // ----- Error log
    PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');

    // ----- Return

    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
    return PclZip::errorCode();
  }

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");

  // ----- Read each entry
  for ($i = 0; $i < $v_central_dir['entries']; $i++) {

    // ----- Read the file header
    if (($v_result = $this
      ->privReadCentralFileHeader($v_header)) != 1) {
      $this
        ->privSwapBackMagicQuotes();

      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
      return $v_result;
    }
    $v_header['index'] = $i;

    // ----- Get the only interesting attributes
    $this
      ->privConvertHeader2FileInfo($v_header, $p_list[$i]);
    unset($v_header);
  }

  // ----- Close the zip file
  $this
    ->privCloseFd();

  // ----- Magic quotes trick
  $this
    ->privSwapBackMagicQuotes();

  // ----- Return

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