You are here

function PclZip::privAddFileList in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/lib/pclzip/pclzip.lib.php \PclZip::privAddFileList()
2 calls to PclZip::privAddFileList()
PclZip::privAdd in includes/moodle/lib/pclzip/pclzip.lib.php
PclZip::privAddList in includes/moodle/lib/pclzip/pclzip.lib.php

File

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

Class

PclZip

Code

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

  //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list");
  $v_result = 1;
  $v_header = array();

  // ----- Recuperate the current number of elt in list
  $v_nb = sizeof($p_result_list);

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements");

  // ----- Loop on the files
  for ($j = 0; $j < sizeof($p_filedescr_list) && $v_result == 1; $j++) {

    // ----- Format the filename
    $p_filedescr_list[$j]['filename'] = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);

    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file '".$p_filedescr_list[$j]['filename']."'");

    // ----- Skip empty file names
    // TBC : Can this be possible ? not checked in DescrParseAtt ?
    if ($p_filedescr_list[$j]['filename'] == "") {

      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");
      continue;
    }

    // ----- Check the filename
    if (!file_exists($p_filedescr_list[$j]['filename'])) {

      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_filedescr_list[$j]['filename']."' does not exists");
      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '" . $p_filedescr_list[$j]['filename'] . "' does not exists");

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

    // ----- Look if it is a file or a dir with no all path remove option
    if (is_file($p_filedescr_list[$j]['filename']) || is_dir($p_filedescr_list[$j]['filename']) && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {

      // ----- Add the file
      $v_result = $this
        ->privAddFile($p_filedescr_list[$j], $v_header, $p_options);
      if ($v_result != 1) {

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

      // ----- Store the file infos
      $p_result_list[$v_nb++] = $v_header;
    }
  }

  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements");

  // ----- Return

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