You are here

function PclZip::privExtractFileAsString in Quiz 6.5

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

File

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

Class

PclZip

Code

function privExtractFileAsString(&$p_entry, &$p_string) {

  //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");
  $v_result = 1;

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

    // ----- Return

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

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");

  // ----- Check that the file header is coherent with $p_entry info
  if ($this
    ->privCheckFileHeaders($v_header, $p_entry) != 1) {

    // TBC
  }

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'");

  // ----- Do the extraction (if not a folder)
  if (!(($p_entry['external'] & 0x10) == 0x10)) {

    // ----- Look for not compressed file
    //      if ($p_entry['compressed_size'] == $p_entry['size'])
    if ($p_entry['compression'] == 0) {

      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");

      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");

      // ----- Reading the file
      $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
    }
    else {

      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')");

      // ----- Reading the file
      $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);

      // ----- Decompress the file
      if (($p_string = @gzinflate($v_data)) === FALSE) {

        // TBC
      }
    }

    // ----- Trace

    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
  }
  else {

    // TBC : error : can not extract a folder in a string
  }

  // ----- Return

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