]> git.mjollnir.org Git - moodle.git/commitdiff
comments for file, class and public methods converted to phpdoc style comments
authordhawes <dhawes>
Tue, 28 Sep 2004 02:16:42 +0000 (02:16 +0000)
committerdhawes <dhawes>
Tue, 28 Sep 2004 02:16:42 +0000 (02:16 +0000)
lib/pclzip/pclzip.lib.php

index 466997cdf18a4e385f2f748759675f02d046a442..a53b06adfa5964c3c1cedf8dd3d3ccc024b7acd0 100644 (file)
-<?php\r
-// --------------------------------------------------------------------------------\r
-// PhpConcept Library - Zip Module 2.0-rc2\r
-// --------------------------------------------------------------------------------\r
-// License GNU/LGPL - Vincent Blavet - July 2003\r
-// http://www.phpconcept.net\r
-// --------------------------------------------------------------------------------\r
-//\r
-// Presentation :\r
-//   PclZip is a PHP library that manage ZIP archives.\r
-//   So far tests show that archives generated by PclZip are readable by\r
-//   WinZip application and other tools.\r
-//\r
-// Description :\r
-//   See readme.txt and http://www.phpconcept.net\r
-//\r
-// Warning :\r
-//   This library and the associated files are non commercial, non professional\r
-//   work.\r
-//   It should not have unexpected results. However if any damage is caused by\r
-//   this software the author can not be responsible.\r
-//   The use of this software is at the risk of the user.\r
-//\r
-// --------------------------------------------------------------------------------\r
-// $Id$\r
-// --------------------------------------------------------------------------------\r
-\r
-  // ----- Constants\r
-  define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );\r
-  \r
-  // ----- File list separator\r
-  // In version 1.x of PclZip, the separator for file list is a space\r
-  // (which is not a very smart choice, specifically for windows paths !).\r
-  // A better separator should be a comma (,). This constant gives you the\r
-  // abilty to change that.\r
-  // However notice that changing this value, may have impact on existing\r
-  // scripts, using space separated filenames.\r
-  // Recommanded values for compatibility with older versions :\r
-  //define( 'PCLZIP_SEPARATOR', ' ' );\r
-  // Recommanded values for smart separation of filenames.\r
-  define( 'PCLZIP_SEPARATOR', ',' );\r
-\r
-  // ----- Error configuration\r
-  // 0 : PclZip Class integrated error handling\r
-  // 1 : PclError external library error handling. By enabling this\r
-  //     you must ensure that you have included PclError library.\r
-  // [2,...] : reserved for futur use\r
-  define( 'PCLZIP_ERROR_EXTERNAL', 0 );\r
-\r
-  // ----- Optional static temporary directory\r
-  //       By default temporary files are generated in the script current\r
-  //       path.\r
-  //       If defined :\r
-  //       - MUST BE terminated by a '/'.\r
-  //       - MUST be a valid, already created directory\r
-  //       Samples :\r
-  // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );\r
-  // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );\r
-  define( 'PCLZIP_TEMPORARY_DIR', '' );\r
-\r
-// --------------------------------------------------------------------------------\r
-// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****\r
-// --------------------------------------------------------------------------------\r
-\r
-  // ----- Global variables\r
-  $g_pclzip_version = "2.0-rc2";\r
-\r
-  // ----- Error codes\r
-  //   -1 : Unable to open file in binary write mode\r
-  //   -2 : Unable to open file in binary read mode\r
-  //   -3 : Invalid parameters\r
-  //   -4 : File does not exist\r
-  //   -5 : Filename is too long (max. 255)\r
-  //   -6 : Not a valid zip file\r
-  //   -7 : Invalid extracted file size\r
-  //   -8 : Unable to create directory\r
-  //   -9 : Invalid archive extension\r
-  //  -10 : Invalid archive format\r
-  //  -11 : Unable to delete file (unlink)\r
-  //  -12 : Unable to rename file (rename)\r
-  //  -13 : Invalid header checksum\r
-  //  -14 : Invalid archive size\r
-  define( 'PCLZIP_ERR_NO_ERROR', 0 );\r
-  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );\r
-  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );\r
-  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );\r
-  define( 'PCLZIP_ERR_MISSING_FILE', -4 );\r
-  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );\r
-  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );\r
-  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );\r
-  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );\r
-  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );\r
-  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );\r
-  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );\r
-  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );\r
-  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );\r
-  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );\r
-  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );\r
-  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );\r
-\r
-  // ----- Options values\r
-  define( 'PCLZIP_OPT_PATH', 77001 );\r
-  define( 'PCLZIP_OPT_ADD_PATH', 77002 );\r
-  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );\r
-  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );\r
-  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );\r
-  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );\r
-  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );\r
-  define( 'PCLZIP_OPT_BY_NAME', 77008 );\r
-  define( 'PCLZIP_OPT_BY_INDEX', 77009 );\r
-  define( 'PCLZIP_OPT_BY_EREG', 77010 );\r
-  define( 'PCLZIP_OPT_BY_PREG', 77011 );\r
-\r
-  // ----- Call backs values\r
-  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );\r
-  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );\r
-  define( 'PCLZIP_CB_PRE_ADD', 78003 );\r
-  define( 'PCLZIP_CB_POST_ADD', 78004 );\r
-  /* For futur use\r
-  define( 'PCLZIP_CB_PRE_LIST', 78005 );\r
-  define( 'PCLZIP_CB_POST_LIST', 78006 );\r
-  define( 'PCLZIP_CB_PRE_DELETE', 78007 );\r
-  define( 'PCLZIP_CB_POST_DELETE', 78008 );\r
-  */\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Class : PclZip\r
-  // Description :\r
-  //   PclZip is the class that represent a Zip archive.\r
-  //   The public methods allow the manipulation of the archive.\r
-  // Attributes :\r
-  //   Attributes must not be accessed directly.\r
-  // Methods :\r
-  //   PclZip() : Object creator\r
-  //   create() : Creates the Zip archive\r
-  //   listContent() : List the content of the Zip archive\r
-  //   extract() : Extract the content of the archive\r
-  //   properties() : List the properties of the archive\r
-  // --------------------------------------------------------------------------------\r
-  class PclZip\r
-  {\r
-    // ----- Filename of the zip file\r
-    var $zipname = '';\r
-\r
-    // ----- File descriptor of the zip file\r
-    var $zip_fd = 0;\r
-\r
-    // ----- Internal error handling\r
-    var $error_code = 1;\r
-    var $error_string = '';\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : PclZip()\r
-  // Description :\r
-  //   Creates a PclZip object and set the name of the associated Zip archive\r
-  //   filename.\r
-  //   Note that no real action is taken, if the archive does not exist it is not\r
-  //   created. Use create() for that.\r
-  // --------------------------------------------------------------------------------\r
-  function PclZip($p_zipname)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");\r
-\r
-    // ----- Tests the zlib\r
-    if (!function_exists('gzopen'))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");\r
-      die('Abort '.basename(__FILE__).' : Missing zlib extensions');\r
-    }\r
-\r
-    // ----- Set the attributes\r
-    $this->zipname = $p_zipname;\r
-    $this->zip_fd = 0;\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);\r
-    return;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function :\r
-  //   create($p_filelist, $p_add_dir="", $p_remove_dir="")\r
-  //   create($p_filelist, $p_option, $p_option_value, ...)\r
-  // Description :\r
-  //   This method supports two different synopsis. The first one is historical.\r
-  //   This method creates a Zip Archive. The Zip file is created in the\r
-  //   filesystem. The files and directories indicated in $p_filelist\r
-  //   are added in the archive. See the parameters description for the\r
-  //   supported format of $p_filelist.\r
-  //   When a directory is in the list, the directory and its content is added\r
-  //   in the archive.\r
-  //   In this synopsis, the function takes an optional variable list of\r
-  //   options. See bellow the supported options.\r
-  // Parameters :\r
-  //   $p_filelist : An array containing file or directory names, or\r
-  //                 a string containing one filename or one directory name, or\r
-  //                 a string containing a list of filenames and/or directory\r
-  //                 names separated by spaces.\r
-  //   $p_add_dir : A path to add before the real path of the archived file,\r
-  //                in order to have it memorized in the archive.\r
-  //   $p_remove_dir : A path to remove from the real path of the file to archive,\r
-  //                   in order to have a shorter path memorized in the archive.\r
-  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir\r
-  //                   is removed first, before $p_add_dir is added.\r
-  // Options :\r
-  //   PCLZIP_OPT_ADD_PATH :\r
-  //   PCLZIP_OPT_REMOVE_PATH :\r
-  //   PCLZIP_OPT_REMOVE_ALL_PATH :\r
-  //   PCLZIP_CB_PRE_ADD :\r
-  //   PCLZIP_CB_POST_ADD :\r
-  // Return Values :\r
-  //   0 on failure,\r
-  //   The list of the added files, with a status of the add action.\r
-  //   (see PclZip::listContent() for list entry format)\r
-  // --------------------------------------------------------------------------------\r
-//  function create($p_filelist, $p_add_dir="", $p_remove_dir="")\r
-  function create($p_filelist /*, options */)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");\r
-    $v_result=1;\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Set default values\r
-    $v_options = array();\r
-    $v_add_path = "";\r
-    $v_remove_path = "";\r
-    $v_remove_all_path = false;\r
-    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;\r
-\r
-    // ----- Look for variable options arguments\r
-    $v_size = func_num_args();\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
-\r
-    // ----- Look for arguments\r
-    if ($v_size > 1) {\r
-      // ----- Get the arguments\r
-      $v_arg_list = &func_get_args();\r
-\r
-      // ----- Remove form the options list the first argument\r
-      array_shift($v_arg_list);\r
-      $v_size--;\r
-\r
-      // ----- Look for first arg\r
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");\r
-\r
-        // ----- Parse the options\r
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,\r
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',\r
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',\r
-                                                   PCLZIP_CB_PRE_ADD => 'optional',\r
-                                                   PCLZIP_CB_POST_ADD => 'optional',\r
-                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional' ));\r
-        if ($v_result != 1) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-          return 0;\r
-        }\r
-\r
-        // ----- Set the arguments\r
-        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {\r
-          $v_add_path = $v_options[PCLZIP_OPT_ADD_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {\r
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
-        }\r
-      }\r
-\r
-      // ----- Look for 2 args\r
-      // Here we need to support the first historic synopsis of the\r
-      // method.\r
-      else {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");\r
-\r
-        // ----- Get the first argument\r
-        $v_add_path = $v_arg_list[0];\r
-\r
-        // ----- Look for the optional second argument\r
-        if ($v_size == 2) {\r
-          $v_remove_path = $v_arg_list[1];\r
-        }\r
-        else if ($v_size > 2) {\r
-          // ----- Error log\r
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");\r
-\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-          return 0;\r
-        }\r
-      }\r
-    }\r
-\r
-    // ----- Trace\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");\r
-\r
-    // ----- Look if the $p_filelist is really an array\r
-    $p_result_list = array();\r
-    if (is_array($p_filelist))\r
-    {\r
-      // ----- Call the create fct\r
-      $v_result = $this->privCreate($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
-    }\r
-\r
-    // ----- Look if the $p_filelist is a string\r
-    else if (is_string($p_filelist))\r
-    {\r
-      // ----- Create a list with the elements from the string\r
-      $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);\r
-\r
-      // ----- Call the create fct\r
-      $v_result = $this->privCreate($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
-    }\r
-\r
-    // ----- Invalid variable\r
-    else\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");\r
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;\r
-    }\r
-\r
-    if ($v_result != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-      return 0;\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);\r
-    return $p_result_list;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function :\r
-  //   add($p_filelist, $p_add_dir="", $p_remove_dir="")\r
-  //   add($p_filelist, $p_option, $p_option_value, ...)\r
-  // Description :\r
-  //   This method supports two synopsis. The first one is historical.\r
-  //   This methods add the list of files in an existing archive.\r
-  //   If a file with the same name already exists, it is added at the end of the\r
-  //   archive, the first one is still present.\r
-  //   If the archive does not exist, it is created.\r
-  // Parameters :\r
-  //   $p_filelist : An array containing file or directory names, or\r
-  //                 a string containing one filename or one directory name, or\r
-  //                 a string containing a list of filenames and/or directory\r
-  //                 names separated by spaces.\r
-  //   $p_add_dir : A path to add before the real path of the archived file,\r
-  //                in order to have it memorized in the archive.\r
-  //   $p_remove_dir : A path to remove from the real path of the file to archive,\r
-  //                   in order to have a shorter path memorized in the archive.\r
-  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir\r
-  //                   is removed first, before $p_add_dir is added.\r
-  // Options :\r
-  //   PCLZIP_OPT_ADD_PATH :\r
-  //   PCLZIP_OPT_REMOVE_PATH :\r
-  //   PCLZIP_OPT_REMOVE_ALL_PATH :\r
-  //   PCLZIP_CB_PRE_ADD :\r
-  //   PCLZIP_CB_POST_ADD :\r
-  // Return Values :\r
-  //   0 on failure,\r
-  //   The list of the added files, with a status of the add action.\r
-  //   (see PclZip::listContent() for list entry format)\r
-  // --------------------------------------------------------------------------------\r
-//  function add($p_filelist, $p_add_dir="", $p_remove_dir="")\r
-  function add($p_filelist /* options */)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");\r
-    $v_result=1;\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Set default values\r
-    $v_options = array();\r
-    $v_add_path = "";\r
-    $v_remove_path = "";\r
-    $v_remove_all_path = false;\r
-    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;\r
-\r
-    // ----- Look for variable options arguments\r
-    $v_size = func_num_args();\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
-\r
-    // ----- Look for arguments\r
-    if ($v_size > 1) {\r
-      // ----- Get the arguments\r
-      $v_arg_list = &func_get_args();\r
-\r
-      // ----- Remove form the options list the first argument\r
-      array_shift($v_arg_list);\r
-      $v_size--;\r
-\r
-      // ----- Look for first arg\r
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");\r
-\r
-        // ----- Parse the options\r
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,\r
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',\r
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',\r
-                                                   PCLZIP_CB_PRE_ADD => 'optional',\r
-                                                   PCLZIP_CB_POST_ADD => 'optional',\r
-                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional' ));\r
-        if ($v_result != 1) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-          return 0;\r
-        }\r
-\r
-        // ----- Set the arguments\r
-        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {\r
-          $v_add_path = $v_options[PCLZIP_OPT_ADD_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {\r
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
-        }\r
-      }\r
-\r
-      // ----- Look for 2 args\r
-      // Here we need to support the first historic synopsis of the\r
-      // method.\r
-      else {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");\r
-\r
-        // ----- Get the first argument\r
-        $v_add_path = $v_arg_list[0];\r
-\r
-        // ----- Look for the optional second argument\r
-        if ($v_size == 2) {\r
-          $v_remove_path = $v_arg_list[1];\r
-        }\r
-        else if ($v_size > 2) {\r
-          // ----- Error log\r
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");\r
-\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-          return 0;\r
-        }\r
-      }\r
-    }\r
-\r
-    // ----- Trace\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");\r
-\r
-    // ----- Look if the $p_filelist is really an array\r
-    $p_result_list = array();\r
-    if (is_array($p_filelist))\r
-    {\r
-      // ----- Call the create fct\r
-      $v_result = $this->privAdd($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
-    }\r
-\r
-    // ----- Look if the $p_filelist is a string\r
-    else if (is_string($p_filelist))\r
-    {\r
-      // ----- Create a list with the elements from the string\r
-      $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);\r
-\r
-      // ----- Call the create fct\r
-      $v_result = $this->privAdd($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
-    }\r
-\r
-    // ----- Invalid variable\r
-    else\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");\r
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;\r
-    }\r
-\r
-    if ($v_result != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-      return 0;\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);\r
-    return $p_result_list;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : listContent()\r
-  // Description :\r
-  //   This public method, gives the list of the files and directories, with their\r
-  //   properties.\r
-  //   The properties of each entries in the list are (used also in other functions) :\r
-  //     filename : Name of the file. For a create or add action it is the filename\r
-  //                given by the user. For an extract function it is the filename\r
-  //                of the extracted file.\r
-  //     stored_filename : Name of the file / directory stored in the archive.\r
-  //     size : Size of the stored file.\r
-  //     compressed_size : Size of the file's data compressed in the archive\r
-  //                       (without the headers overhead)\r
-  //     mtime : Last known modification date of the file (UNIX timestamp)\r
-  //     comment : Comment associated with the file\r
-  //     folder : true | false\r
-  //     index : index of the file in the archive\r
-  //     status : status of the action (depending of the action) :\r
-  //              Values are :\r
-  //                ok : OK !\r
-  //                filtered : the file / dir is not extracted (filtered by user)\r
-  //                already_a_directory : the file can not be extracted because a\r
-  //                                      directory with the same name already exists\r
-  //                write_protected : the file can not be extracted because a file\r
-  //                                  with the same name already exists and is\r
-  //                                  write protected\r
-  //                newer_exist : the file was not extracted because a newer file exists\r
-  //                path_creation_fail : the file is not extracted because the folder\r
-  //                                     does not exists and can not be created\r
-  //                write_error : the file was not extracted because there was a\r
-  //                              error while writing the file\r
-  //                read_error : the file was not extracted because there was a error\r
-  //                             while reading the file\r
-  //                invalid_header : the file was not extracted because of an archive\r
-  //                                 format error (bad file header)\r
-  //   Note that each time a method can continue operating when there\r
-  //   is an action error on a file, the error is only logged in the file status.\r
-  // Return Values :\r
-  //   0 on an unrecoverable failure,\r
-  //   The list of the files in the archive.\r
-  // --------------------------------------------------------------------------------\r
-  function listContent()\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");\r
-    $v_result=1;\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Check archive\r
-    if (!$this->privCheckFormat()) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-      return(0);\r
-    }\r
-\r
-    // ----- Call the extracting fct\r
-    $p_list = array();\r
-    if (($v_result = $this->privList($p_list)) != 1)\r
-    {\r
-      unset($p_list);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
-      return(0);\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);\r
-    return $p_list;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function :\r
-  //   extract($p_path="./", $p_remove_path="")\r
-  //   extract([$p_option, $p_option_value, ...])\r
-  // Description :\r
-  //   This method supports two synopsis. The first one is historical.\r
-  //   This method extract all the files / directories from the archive to the\r
-  //   folder indicated in $p_path.\r
-  //   If you want to ignore the 'root' part of path of the memorized files\r
-  //   you can indicate this in the optional $p_remove_path parameter.\r
-  //   By default, if a newer file with the same name already exists, the\r
-  //   file is not extracted.\r
-  //\r
-  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions\r
-  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append\r
-  //   at the end of the path value of PCLZIP_OPT_PATH.\r
-  // Parameters :\r
-  //   $p_path : Path where the files and directories are to be extracted\r
-  //   $p_remove_path : First part ('root' part) of the memorized path\r
-  //                    (if any similar) to remove while extracting.\r
-  // Options :\r
-  //   PCLZIP_OPT_PATH :\r
-  //   PCLZIP_OPT_ADD_PATH :\r
-  //   PCLZIP_OPT_REMOVE_PATH :\r
-  //   PCLZIP_OPT_REMOVE_ALL_PATH :\r
-  //   PCLZIP_CB_PRE_EXTRACT :\r
-  //   PCLZIP_CB_POST_EXTRACT :\r
-  // Return Values :\r
-  //   0 or a negative value on failure,\r
-  //   The list of the extracted files, with a status of the action.\r
-  //   (see PclZip::listContent() for list entry format)\r
-  // --------------------------------------------------------------------------------\r
-  //function extract($p_path="./", $p_remove_path="")\r
-  function extract(/* options */)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");\r
-    $v_result=1;\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Check archive\r
-    if (!$this->privCheckFormat()) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-      return(0);\r
-    }\r
-\r
-    // ----- Set default values\r
-    $v_options = array();\r
-    $v_path = "./";\r
-    $v_remove_path = "";\r
-    $v_remove_all_path = false;\r
-\r
-    // ----- Look for variable options arguments\r
-    $v_size = func_num_args();\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
-\r
-    // ----- Default values for option\r
-    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;\r
-\r
-    // ----- Look for arguments\r
-    if ($v_size > 0) {\r
-      // ----- Get the arguments\r
-      $v_arg_list = &func_get_args();\r
-\r
-      // ----- Look for first arg\r
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");\r
-\r
-        // ----- Parse the options\r
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,\r
-                                            array (PCLZIP_OPT_PATH => 'optional',\r
-                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',\r
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',\r
-                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',\r
-                                                   PCLZIP_CB_POST_EXTRACT => 'optional',\r
-                                                   PCLZIP_OPT_SET_CHMOD => 'optional',\r
-                                                   PCLZIP_OPT_BY_NAME => 'optional',\r
-                                                   PCLZIP_OPT_BY_EREG => 'optional',\r
-                                                   PCLZIP_OPT_BY_PREG => 'optional',\r
-                                                   PCLZIP_OPT_BY_INDEX => 'optional',\r
-                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional' ));\r
-        if ($v_result != 1) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-          return 0;\r
-        }\r
-\r
-        // ----- Set the arguments\r
-        if (isset($v_options[PCLZIP_OPT_PATH])) {\r
-          $v_path = $v_options[PCLZIP_OPT_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {\r
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {\r
-          // ----- Check for '/' in last path char\r
-          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {\r
-            $v_path .= '/';\r
-          }\r
-          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];\r
-        }\r
-      }\r
-\r
-      // ----- Look for 2 args\r
-      // Here we need to support the first historic synopsis of the\r
-      // method.\r
-      else {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");\r
-\r
-        // ----- Get the first argument\r
-        $v_path = $v_arg_list[0];\r
-\r
-        // ----- Look for the optional second argument\r
-        if ($v_size == 2) {\r
-          $v_remove_path = $v_arg_list[1];\r
-        }\r
-        else if ($v_size > 2) {\r
-          // ----- Error log\r
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");\r
-\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
-          return 0;\r
-        }\r
-      }\r
-    }\r
-\r
-    // ----- Trace\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");\r
-\r
-    // ----- Call the extracting fct\r
-    $p_list = array();\r
-    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1)\r
-    {\r
-      unset($p_list);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
-      return(0);\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);\r
-    return $p_list;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function :\r
-  //   extractByIndex($p_index, $p_path="./", $p_remove_path="")\r
-  //   extractByIndex($p_index, [$p_option, $p_option_value, ...])\r
-  // Description :\r
-  //   This method supports two synopsis. The first one is historical.\r
-  //   This method is doing a partial extract of the archive.\r
-  //   The extracted files or folders are identified by their index in the\r
-  //   archive (from 0 to n).\r
-  //   Note that if the index identify a folder, only the folder entry is\r
-  //   extracted, not all the files included in the archive.\r
-  // Parameters :\r
-  //   $p_index : A single index (integer) or a string of indexes of files to\r
-  //              extract. The form of the string is "0,4-6,8-12" with only numbers\r
-  //              and '-' for range or ',' to separate ranges. No spaces or ';'\r
-  //              are allowed.\r
-  //   $p_path : Path where the files and directories are to be extracted\r
-  //   $p_remove_path : First part ('root' part) of the memorized path\r
-  //                    (if any similar) to remove while extracting.\r
-  // Options :\r
-  //   PCLZIP_OPT_PATH :\r
-  //   PCLZIP_OPT_ADD_PATH :\r
-  //   PCLZIP_OPT_REMOVE_PATH :\r
-  //   PCLZIP_OPT_REMOVE_ALL_PATH :\r
-  //   PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and\r
-  //     not as files.\r
-  //     The resulting content is in a new field 'content' in the file\r
-  //     structure.\r
-  //     This option must be used alone (any other options are ignored).\r
-  //   PCLZIP_CB_PRE_EXTRACT :\r
-  //   PCLZIP_CB_POST_EXTRACT :\r
-  // Return Values :\r
-  //   0 on failure,\r
-  //   The list of the extracted files, with a status of the action.\r
-  //   (see PclZip::listContent() for list entry format)\r
-  // --------------------------------------------------------------------------------\r
-  function extractByIndex($p_index /* $options */)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");\r
-    $v_result=1;\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Check archive\r
-    if (!$this->privCheckFormat()) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-      return(0);\r
-    }\r
-\r
-    // ----- Set default values\r
-    $v_options = array();\r
-    $v_path = "./";\r
-    $v_remove_path = "";\r
-    $v_remove_all_path = false;\r
-\r
-    // ----- Look for variable options arguments\r
-    $v_size = func_num_args();\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
-\r
-    // ----- Default values for option\r
-    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;\r
-\r
-    // ----- Look for arguments\r
-    if ($v_size > 1) {\r
-      // ----- Get the arguments\r
-      $v_arg_list = &func_get_args();\r
-\r
-      // ----- Remove form the options list the first argument\r
-      array_shift($v_arg_list);\r
-      $v_size--;\r
-\r
-      // ----- Look for first arg\r
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");\r
-\r
-        // ----- Parse the options\r
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,\r
-                                            array (PCLZIP_OPT_PATH => 'optional',\r
-                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',\r
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
-                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',\r
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',\r
-                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',\r
-                                                   PCLZIP_CB_POST_EXTRACT => 'optional',\r
-                                                   PCLZIP_OPT_SET_CHMOD => 'optional' ));\r
-        if ($v_result != 1) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-          return 0;\r
-        }\r
-\r
-        // ----- Set the arguments\r
-        if (isset($v_options[PCLZIP_OPT_PATH])) {\r
-          $v_path = $v_options[PCLZIP_OPT_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {\r
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
-        }\r
-        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {\r
-          // ----- Check for '/' in last path char\r
-          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {\r
-            $v_path .= '/';\r
-          }\r
-          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];\r
-        }\r
-        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {\r
-          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");\r
-        }\r
-        else {\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");\r
-        }\r
-      }\r
-\r
-      // ----- Look for 2 args\r
-      // Here we need to support the first historic synopsis of the\r
-      // method.\r
-      else {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");\r
-\r
-        // ----- Get the first argument\r
-        $v_path = $v_arg_list[0];\r
-\r
-        // ----- Look for the optional second argument\r
-        if ($v_size == 2) {\r
-          $v_remove_path = $v_arg_list[1];\r
-        }\r
-        else if ($v_size > 2) {\r
-          // ----- Error log\r
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");\r
-\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-          return 0;\r
-        }\r
-      }\r
-    }\r
-\r
-    // ----- Trace\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");\r
-\r
-    // ----- Trick\r
-    // Here I want to reuse extractByRule(), so I need to parse the $p_index\r
-    // with privParseOptions()\r
-    $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);\r
-    $v_options_trick = array();\r
-    $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,\r
-                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));\r
-    if ($v_result != 1) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-        return 0;\r
-    }\r
-    $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];\r
-\r
-    // ----- Call the extracting fct\r
-    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
-        return(0);\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);\r
-    return $p_list;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function :\r
-  //   delete([$p_option, $p_option_value, ...])\r
-  // Description :\r
-  // Parameters :\r
-  //   None\r
-  // Options :\r
-  //   PCLZIP_OPT_BY_INDEX :\r
-  // Return Values :\r
-  //   0 on failure,\r
-  //   The list of the files which are still present in the archive.\r
-  //   (see PclZip::listContent() for list entry format)\r
-  // --------------------------------------------------------------------------------\r
-  function delete(/* options */)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");\r
-    $v_result=1;\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Check archive\r
-    if (!$this->privCheckFormat()) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-      return(0);\r
-    }\r
-\r
-    // ----- Set default values\r
-    $v_options = array();\r
-\r
-    // ----- Look for variable options arguments\r
-    $v_size = func_num_args();\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
-\r
-    // ----- Look for no arguments\r
-    if ($v_size <= 0) {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing arguments");\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
-        return 0;\r
-    }\r
-\r
-    // ----- Get the arguments\r
-    $v_arg_list = &func_get_args();\r
-\r
-    // ----- Parse the options\r
-    $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,\r
-                                        array (PCLZIP_OPT_BY_NAME => 'optional',\r
-                                               PCLZIP_OPT_BY_EREG => 'optional',\r
-                                               PCLZIP_OPT_BY_PREG => 'optional',\r
-                                               PCLZIP_OPT_BY_INDEX => 'optional' ));\r
-    if ($v_result != 1) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-        return 0;\r
-    }\r
-\r
-    // ----- Check that at least one rule is set\r
-    if (   (!isset($v_options[PCLZIP_OPT_BY_NAME]))\r
-        && (!isset($v_options[PCLZIP_OPT_BY_EREG]))\r
-        && (!isset($v_options[PCLZIP_OPT_BY_PREG]))\r
-        && (!isset($v_options[PCLZIP_OPT_BY_INDEX]))) {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "At least one filtering rule must be set");\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
-        return 0;\r
-    }\r
-\r
-    // ----- Call the delete fct\r
-    $v_list = array();\r
-    if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1)\r
-    {\r
-      unset($v_list);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
-      return(0);\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);\r
-    return $v_list;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : deleteByIndex()\r
-  // Description :\r
-  //   ***** Deprecated *****\r
-  //   delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.\r
-  // --------------------------------------------------------------------------------\r
-  function deleteByIndex($p_index)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");\r
-    \r
-    $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);\r
-    return $p_list;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : properties()\r
-  // Description :\r
-  //   This method gives the properties of the archive.\r
-  //   The properties are :\r
-  //     nb : Number of files in the archive\r
-  //     comment : Comment associated with the archive file\r
-  //     status : not_exist, ok\r
-  // Parameters :\r
-  //   None\r
-  // Return Values :\r
-  //   0 on failure,\r
-  //   An array with the archive properties.\r
-  // --------------------------------------------------------------------------------\r
-  function properties()\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Check archive\r
-    if (!$this->privCheckFormat()) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-      return(0);\r
-    }\r
-\r
-    // ----- Default properties\r
-    $v_prop = array();\r
-    $v_prop['comment'] = '';\r
-    $v_prop['nb'] = 0;\r
-    $v_prop['status'] = 'not_exist';\r
-\r
-    // ----- Look if file exists\r
-    if (@is_file($this->zipname))\r
-    {\r
-      // ----- Open the zip file\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-      if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)\r
-      {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);\r
-        return 0;\r
-      }\r
-\r
-      // ----- Read the central directory informations\r
-      $v_central_dir = array();\r
-      if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-        return 0;\r
-      }\r
-\r
-      // ----- Close the zip file\r
-      $this->privCloseFd();\r
-\r
-      // ----- Set the user attributes\r
-      $v_prop['comment'] = $v_central_dir['comment'];\r
-      $v_prop['nb'] = $v_central_dir['entries'];\r
-      $v_prop['status'] = 'ok';\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);\r
-    return $v_prop;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : duplicate()\r
-  // Description :\r
-  //   This method creates an archive by copying the content of an other one. If\r
-  //   the archive already exist, it is replaced by the new one without any warning.\r
-  // Parameters :\r
-  //   $p_archive : The filename of a valid archive, or\r
-  //                a valid PclZip object.\r
-  // Return Values :\r
-  //   1 on success.\r
-  //   0 or a negative value on error (error code).\r
-  // --------------------------------------------------------------------------------\r
-  function duplicate($p_archive)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");\r
-    $v_result = 1;\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Look if the $p_archive is a PclZip object\r
-    if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");\r
-\r
-      // ----- Duplicate the archive\r
-      $v_result = $this->privDuplicate($p_archive->zipname);\r
-    }\r
-\r
-    // ----- Look if the $p_archive is a string (so a filename)\r
-    else if (is_string($p_archive))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'");\r
-\r
-      // ----- Check that $p_archive is a valid zip file\r
-      // TBC : Should also check the archive format\r
-      if (!is_file($p_archive)) {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");\r
-        $v_result = PCLZIP_ERR_MISSING_FILE;\r
-      }\r
-      else {\r
-        // ----- Duplicate the archive\r
-        $v_result = $this->privDuplicate($p_archive);\r
-      }\r
-    }\r
-\r
-    // ----- Invalid variable\r
-    else\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");\r
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : merge()\r
-  // Description :\r
-  //   This method merge the $p_archive_to_add archive at the end of the current\r
-  //   one ($this).\r
-  //   If the archive ($this) does not exist, the merge becomes a duplicate.\r
-  //   If the $p_archive_to_add archive does not exist, the merge is a success.\r
-  // Parameters :\r
-  //   $p_archive_to_add : It can be directly the filename of a valid zip archive,\r
-  //                       or a PclZip object archive.\r
-  // Return Values :\r
-  //   1 on success,\r
-  //   0 or negative values on error (see below).\r
-  // --------------------------------------------------------------------------------\r
-  function merge($p_archive_to_add)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");\r
-    $v_result = 1;\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Check archive\r
-    if (!$this->privCheckFormat()) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
-      return(0);\r
-    }\r
-\r
-    // ----- Look if the $p_archive_to_add is a PclZip object\r
-    if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");\r
-\r
-      // ----- Merge the archive\r
-      $v_result = $this->privMerge($p_archive_to_add);\r
-    }\r
-\r
-    // ----- Look if the $p_archive_to_add is a string (so a filename)\r
-    else if (is_string($p_archive_to_add))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");\r
-\r
-      // ----- Create a temporary archive\r
-      $v_object_archive = new PclZip($p_archive_to_add);\r
-\r
-      // ----- Merge the archive\r
-      $v_result = $this->privMerge($v_object_archive);\r
-    }\r
-\r
-    // ----- Invalid variable\r
-    else\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");\r
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : errorCode()\r
-  // Description :\r
-  // Parameters :\r
-  // --------------------------------------------------------------------------------\r
-  function errorCode()\r
-  {\r
-    if (PCLZIP_ERROR_EXTERNAL == 1) {\r
-      return(PclErrorCode());\r
-    }\r
-    else {\r
-      return($this->error_code);\r
-    }\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : errorName()\r
-  // Description :\r
-  // Parameters :\r
-  // --------------------------------------------------------------------------------\r
-  function errorName($p_with_code=false)\r
-  {\r
-    $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',\r
-                      PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',\r
-                      PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',\r
-                      PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',\r
-                      PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',\r
-                      PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',\r
-                      PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',\r
-                      PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',\r
-                      PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',\r
-                      PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',\r
-                      PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',\r
-                      PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',\r
-                      PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',\r
-                      PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',\r
-                      PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',\r
-                      PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',\r
-                      PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE' );\r
-\r
-    if (isset($v_name[$this->error_code])) {\r
-      $v_value = $v_name[$this->error_code];\r
-    }\r
-    else {\r
-      $v_value = 'NoName';\r
-    }\r
-\r
-    if ($p_with_code) {\r
-      return($v_value.' ('.$this->error_code.')');\r
-    }\r
-    else {\r
-      return($v_value);\r
-    }\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : errorInfo()\r
-  // Description :\r
-  // Parameters :\r
-  // --------------------------------------------------------------------------------\r
-  function errorInfo($p_full=false)\r
-  {\r
-    if (PCLZIP_ERROR_EXTERNAL == 1) {\r
-      return(PclErrorString());\r
-    }\r
-    else {\r
-      if ($p_full) {\r
-        return($this->errorName(true)." : ".$this->error_string);\r
-      }\r
-      else {\r
-        return($this->error_string." [code ".$this->error_code."]");\r
-      }\r
-    }\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-\r
-// --------------------------------------------------------------------------------\r
-// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****\r
-// *****                                                        *****\r
-// *****       THESES FUNCTIONS MUST NOT BE USED DIRECTLY       *****\r
-// --------------------------------------------------------------------------------\r
-\r
-\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privCheckFormat()\r
-  // Description :\r
-  //   This method check that the archive exists and is a valid zip archive.\r
-  //   Several level of check exists. (futur)\r
-  // Parameters :\r
-  //   $p_level : Level of check. Default 0.\r
-  //              0 : Check the first bytes (magic codes) (default value))\r
-  //              1 : 0 + Check the central directory (futur)\r
-  //              2 : 1 + Check each file header (futur)\r
-  // Return Values :\r
-  //   true on success,\r
-  //   false on error, the error code is set.\r
-  // --------------------------------------------------------------------------------\r
-  function privCheckFormat($p_level=0)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");\r
-    $v_result = true;\r
-\r
-    // ----- Reset the error handler\r
-    $this->privErrorReset();\r
-\r
-    // ----- Look if the file exits\r
-    if (!is_file($this->zipname)) {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());\r
-      return(false);\r
-    }\r
-\r
-    // ----- Check that the file is readeable\r
-    if (!is_readable($this->zipname)) {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());\r
-      return(false);\r
-    }\r
-\r
-    // ----- Check the magic code\r
-    // TBC\r
-\r
-    // ----- Check the central header\r
-    // TBC\r
-\r
-    // ----- Check each file header\r
-    // TBC\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privParseOptions()\r
-  // Description :\r
-  //   This internal methods reads the variable list of arguments ($p_options_list,\r
-  //   $p_size) and generate an array with the options and values ($v_result_list).\r
-  //   $v_requested_options contains the options that can be present and those that\r
-  //   must be present.\r
-  //   $v_requested_options is an array, with the option value as key, and 'optional',\r
-  //   or 'mandatory' as value.\r
-  // Parameters :\r
-  //   See above.\r
-  // Return Values :\r
-  //   1 on success.\r
-  //   0 on failure.\r
-  // --------------------------------------------------------------------------------\r
-  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");\r
-    $v_result=1;\r
-\r
-    // ----- Read the options\r
-    $i=0;\r
-    while ($i<$p_size) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");\r
-\r
-      // ----- Check if the option is requested\r
-      if (!isset($v_requested_options[$p_options_list[$i]])) {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
-\r
-      // ----- Look for next option\r
-      switch ($p_options_list[$i]) {\r
-        // ----- Look for options that request a path value\r
-        case PCLZIP_OPT_PATH :\r
-        case PCLZIP_OPT_REMOVE_PATH :\r
-        case PCLZIP_OPT_ADD_PATH :\r
-          // ----- Check the number of parameters\r
-          if (($i+1) >= $p_size) {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-\r
-          // ----- Get the value\r
-          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
-          $i++;\r
-        break;\r
-\r
-        // ----- Look for options that request an array of string for value\r
-        case PCLZIP_OPT_BY_NAME :\r
-          // ----- Check the number of parameters\r
-          if (($i+1) >= $p_size) {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-\r
-          // ----- Get the value\r
-          if (is_string($p_options_list[$i+1])) {\r
-              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];\r
-          }\r
-          else if (is_array($p_options_list[$i+1])) {\r
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];\r
-          }\r
-          else {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-          ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
-          $i++;\r
-        break;\r
-\r
-        // ----- Look for options that request an EREG or PREG expression\r
-        case PCLZIP_OPT_BY_EREG :\r
-        case PCLZIP_OPT_BY_PREG :\r
-          // ----- Check the number of parameters\r
-          if (($i+1) >= $p_size) {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-\r
-          // ----- Get the value\r
-          if (is_string($p_options_list[$i+1])) {\r
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];\r
-          }\r
-          else {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
-          $i++;\r
-        break;\r
-\r
-        // ----- Look for options that request an array of index\r
-        case PCLZIP_OPT_BY_INDEX :\r
-          // ----- Check the number of parameters\r
-          if (($i+1) >= $p_size) {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-\r
-          // ----- Get the value\r
-          $v_work_list = array();\r
-          if (is_string($p_options_list[$i+1])) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'");\r
-\r
-              // ----- Remove spaces\r
-              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');\r
-\r
-              // ----- Parse items\r
-              $v_work_list = explode(",", $p_options_list[$i+1]);\r
-          }\r
-          else if (is_integer($p_options_list[$i+1])) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'");\r
-              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];\r
-          }\r
-          else if (is_array($p_options_list[$i+1])) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");\r
-              $v_work_list = $p_options_list[$i+1];\r
-          }\r
-          else {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-          \r
-          // ----- Reduce the index list\r
-          // each index item in the list must be a couple with a start and\r
-          // an end value : [0,3], [5-5], [8-10], ...\r
-          // ----- Check the format of each item\r
-          $v_sort_flag=false;\r
-          $v_sort_value=0;\r
-          for ($j=0; $j<sizeof($v_work_list); $j++) {\r
-              // ----- Explode the item\r
-              $v_item_list = explode("-", $v_work_list[$j]);\r
-              $v_size_item_list = sizeof($v_item_list);\r
-              \r
-              // ----- TBC : Here we might check that each item is a\r
-              // real integer ...\r
-              \r
-              // ----- Look for single value\r
-              if ($v_size_item_list == 1) {\r
-                  // ----- Set the option value\r
-                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];\r
-                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];\r
-              }\r
-              elseif ($v_size_item_list == 2) {\r
-                  // ----- Set the option value\r
-                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];\r
-                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];\r
-              }\r
-              else {\r
-                  // ----- Error log\r
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-                  // ----- Return\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-                  return PclZip::errorCode();\r
-              }\r
-\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extracted index item = [".$v_result_list[$p_options_list[$i]][$j]['start'].",".$v_result_list[$p_options_list[$i]][$j]['end']."]");\r
-\r
-              // ----- Look for list sort\r
-              if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");\r
-                  $v_sort_flag=true;\r
-\r
-                  // ----- TBC : An automatic sort should be writen ...\r
-                  // ----- Error log\r
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-                  // ----- Return\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-                  return PclZip::errorCode();\r
-              }\r
-              $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];\r
-          }\r
-          \r
-          // ----- Sort the items\r
-          if ($v_sort_flag) {\r
-              // TBC : To Be Completed\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ...");\r
-          }\r
-\r
-          // ----- Next option\r
-          $i++;\r
-        break;\r
-\r
-        // ----- Look for options that request no value\r
-        case PCLZIP_OPT_REMOVE_ALL_PATH :\r
-        case PCLZIP_OPT_EXTRACT_AS_STRING :\r
-        case PCLZIP_OPT_NO_COMPRESSION :\r
-          $v_result_list[$p_options_list[$i]] = true;\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
-        break;\r
-\r
-        // ----- Look for options that request an octal value\r
-        case PCLZIP_OPT_SET_CHMOD :\r
-          // ----- Check the number of parameters\r
-          if (($i+1) >= $p_size) {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-\r
-          // ----- Get the value\r
-          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
-          $i++;\r
-        break;\r
-\r
-        // ----- Look for options that request a call-back\r
-        case PCLZIP_CB_PRE_EXTRACT :\r
-        case PCLZIP_CB_POST_EXTRACT :\r
-        case PCLZIP_CB_PRE_ADD :\r
-        case PCLZIP_CB_POST_ADD :\r
-        /* for futur use\r
-        case PCLZIP_CB_PRE_DELETE :\r
-        case PCLZIP_CB_POST_DELETE :\r
-        case PCLZIP_CB_PRE_LIST :\r
-        case PCLZIP_CB_POST_LIST :\r
-        */\r
-          // ----- Check the number of parameters\r
-          if (($i+1) >= $p_size) {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-\r
-          // ----- Get the value\r
-          $v_function_name = $p_options_list[$i+1];\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");\r
-\r
-          // ----- Check that the value is a valid existing function\r
-          if (!function_exists($v_function_name)) {\r
-            // ----- Error log\r
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-            return PclZip::errorCode();\r
-          }\r
-\r
-          // ----- Set the attribute\r
-          $v_result_list[$p_options_list[$i]] = $v_function_name;\r
-          $i++;\r
-        break;\r
-\r
-        default :\r
-          // ----- Error log\r
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown optional parameter '".$p_options_list[$i]."'");\r
-\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-          return PclZip::errorCode();\r
-      }\r
-\r
-      // ----- Next options\r
-      $i++;\r
-    }\r
-\r
-    // ----- Look for mandatory options\r
-    for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {\r
-      // ----- Look for mandatory option\r
-      if ($v_requested_options[$key] == 'mandatory') {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");\r
-        // ----- Look if present\r
-        if (!isset($v_result_list[$key])) {\r
-          // ----- Error log\r
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");\r
-\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-          return PclZip::errorCode();\r
-        }\r
-      }\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privCreate()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privCreate($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
-    $v_result=1;\r
-    $v_list_detail = array();\r
-\r
-    // ----- Open the file in write mode\r
-    if (($v_result = $this->privOpenFd('wb')) != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Add the list of files\r
-    $v_result = $this->privAddList($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);\r
-\r
-    // ----- Close\r
-    $this->privCloseFd();\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privAdd()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privAdd($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
-    $v_result=1;\r
-    $v_list_detail = array();\r
-\r
-    // ----- Look if the archive exists or is empty\r
-    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it.");\r
-\r
-      // ----- Do a create\r
-      $v_result = $this->privCreate($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Open the zip file\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-    if (($v_result=$this->privOpenFd('rb')) != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Read the central directory informations\r
-    $v_central_dir = array();\r
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
-    {\r
-      $this->privCloseFd();\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Go to beginning of File\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");\r
-    @rewind($this->zip_fd);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");\r
-\r
-    // ----- Creates a temporay file\r
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';\r
-\r
-    // ----- Open the temporary file in write mode\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)\r
-    {\r
-      $this->privCloseFd();\r
-\r
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Copy the files from the archive to the temporary file\r
-    // TBC : Here I should better append the file and go back to erase the central dir\r
-    $v_size = $v_central_dir['offset'];\r
-    while ($v_size != 0)\r
-    {\r
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-      $v_buffer = fread($this->zip_fd, $v_read_size);\r
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
-      $v_size -= $v_read_size;\r
-    }\r
-\r
-    // ----- Swap the file descriptor\r
-    // Here is a trick : I swap the temporary fd with the zip fd, in order to use\r
-    // the following methods on the temporary fil and not the real archive\r
-    $v_swap = $this->zip_fd;\r
-    $this->zip_fd = $v_zip_temp_fd;\r
-    $v_zip_temp_fd = $v_swap;\r
-\r
-    // ----- Add the files\r
-    $v_header_list = array();\r
-    if (($v_result = $this->privAddFileList($p_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)\r
-    {\r
-      fclose($v_zip_temp_fd);\r
-      $this->privCloseFd();\r
-      @unlink($v_zip_temp_name);\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Store the offset of the central dir\r
-    $v_offset = @ftell($this->zip_fd);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");\r
-\r
-    // ----- Copy the block of file headers from the old archive\r
-    $v_size = $v_central_dir['size'];\r
-    while ($v_size != 0)\r
-    {\r
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);\r
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);\r
-      $v_size -= $v_read_size;\r
-    }\r
-\r
-    // ----- Create the Central Dir files header\r
-    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)\r
-    {\r
-      // ----- Create the file header\r
-      if ($v_header_list[$i]['status'] == 'ok') {\r
-        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {\r
-          fclose($v_zip_temp_fd);\r
-          $this->privCloseFd();\r
-          @unlink($v_zip_temp_name);\r
-\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
-        }\r
-        $v_count++;\r
-      }\r
-\r
-      // ----- Transform the header to a 'usable' info\r
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);\r
-    }\r
-\r
-    // ----- Zip file comment\r
-    $v_comment = '';\r
-\r
-    // ----- Calculate the size of the central header\r
-    $v_size = @ftell($this->zip_fd)-$v_offset;\r
-\r
-    // ----- Create the central dir footer\r
-    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)\r
-    {\r
-      // ----- Reset the file list\r
-      unset($v_header_list);\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Swap back the file descriptor\r
-    $v_swap = $this->zip_fd;\r
-    $this->zip_fd = $v_zip_temp_fd;\r
-    $v_zip_temp_fd = $v_swap;\r
-\r
-    // ----- Close\r
-    $this->privCloseFd();\r
-\r
-    // ----- Close the temporary file\r
-    @fclose($v_zip_temp_fd);\r
-\r
-    // ----- Delete the zip file\r
-    // TBC : I should test the result ...\r
-    @unlink($this->zipname);\r
-\r
-    // ----- Rename the temporary file\r
-    // TBC : I should test the result ...\r
-    //@rename($v_zip_temp_name, $this->zipname);\r
-    PclZipUtilRename($v_zip_temp_name, $this->zipname);\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privOpenFd()\r
-  // Description :\r
-  // Parameters :\r
-  // --------------------------------------------------------------------------------\r
-  function privOpenFd($p_mode)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode);\r
-    $v_result=1;\r
-\r
-    // ----- Look if already open\r
-    if ($this->zip_fd != 0)\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Open the zip file\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');\r
-    if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privCloseFd()\r
-  // Description :\r
-  // Parameters :\r
-  // --------------------------------------------------------------------------------\r
-  function privCloseFd()\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");\r
-    $v_result=1;\r
-\r
-    if ($this->zip_fd != 0)\r
-      @fclose($this->zip_fd);\r
-    $this->zip_fd = 0;\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privAddList()\r
-  // Description :\r
-  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is\r
-  //   different from the real path of the file. This is usefull if you want to have PclTar\r
-  //   running in any directory, and memorize relative path from an other directory.\r
-  // Parameters :\r
-  //   $p_list : An array containing the file or directory names to add in the tar\r
-  //   $p_result_list : list of added files with their properties (specially the status field)\r
-  //   $p_add_dir : Path to add in the filename path archived\r
-  //   $p_remove_dir : Path to remove in the filename path archived\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
-    $v_result=1;\r
-\r
-    // ----- Add the files\r
-    $v_header_list = array();\r
-    if (($v_result = $this->privAddFileList($p_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Store the offset of the central dir\r
-    $v_offset = @ftell($this->zip_fd);\r
-\r
-    // ----- Create the Central Dir files header\r
-    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)\r
-    {\r
-      // ----- Create the file header\r
-      if ($v_header_list[$i]['status'] == 'ok') {\r
-        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
-        }\r
-        $v_count++;\r
-      }\r
-\r
-      // ----- Transform the header to a 'usable' info\r
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);\r
-    }\r
-\r
-    // ----- Zip file comment\r
-    $v_comment = '';\r
-\r
-    // ----- Calculate the size of the central header\r
-    $v_size = @ftell($this->zip_fd)-$v_offset;\r
-\r
-    // ----- Create the central dir footer\r
-    if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)\r
-    {\r
-      // ----- Reset the file list\r
-      unset($v_header_list);\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privAddFileList()\r
-  // Description :\r
-  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is\r
-  //   different from the real path of the file. This is usefull if you want to\r
-  //   run the lib in any directory, and memorize relative path from an other directory.\r
-  // Parameters :\r
-  //   $p_list : An array containing the file or directory names to add in the tar\r
-  //   $p_result_list : list of added files with their properties (specially the status field)\r
-  //   $p_add_dir : Path to add in the filename path archived\r
-  //   $p_remove_dir : Path to remove in the filename path archived\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privAddFileList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
-    $v_result=1;\r
-    $v_header = array();\r
-\r
-    // ----- Recuperate the current number of elt in list\r
-    $v_nb = sizeof($p_result_list);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have $v_nb elements");\r
-\r
-    // ----- Loop on the files\r
-    for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++)\r
-    {\r
-      // ----- Recuperate the filename\r
-      $p_filename = PclZipUtilTranslateWinPath($p_list[$j], false);\r
-\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file [$p_filename]");\r
-\r
-      // ----- Skip empty file names\r
-      if ($p_filename == "")\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");\r
-        continue;\r
-      }\r
-\r
-      // ----- Check the filename\r
-      if (!file_exists($p_filename))\r
-      {\r
-        // ----- Error log\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '$p_filename' does not exists");\r
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '$p_filename' does not exists");\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
-\r
-      /* This test is done later\r
-      // ----- Check the path length\r
-      if (strlen($p_filename) > 0xFF)\r
-      {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(-5, "File name is too long (max. 255) : '$p_filename'");\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
-      */\r
-\r
-      // ----- Look if it is a file or a dir with no all pathnre move\r
-      if ((is_file($p_filename)) || ((is_dir($p_filename)) && !$p_remove_all_dir)) {\r
-        // ----- Add the file\r
-        if (($v_result = $this->privAddFile($p_filename, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)\r
-        {\r
-          // ----- Return status\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
-        }\r
-\r
-        // ----- Store the file infos\r
-        $p_result_list[$v_nb++] = $v_header;\r
-      }\r
-\r
-      // ----- Look for directory\r
-      if (is_dir($p_filename))\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "$p_filename is a directory");\r
-\r
-        // ----- Look for path\r
-        if ($p_filename != ".")\r
-          $v_path = $p_filename."/";\r
-        else\r
-          $v_path = "";\r
-\r
-        // ----- Read the directory for files and sub-directories\r
-        $p_hdir = opendir($p_filename);\r
-        $p_hitem = readdir($p_hdir); // '.' directory\r
-        $p_hitem = readdir($p_hdir); // '..' directory\r
-        while ($p_hitem = readdir($p_hdir))\r
-        {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for $p_hitem in the directory");\r
-\r
-          // ----- Look for a file\r
-          if (is_file($v_path.$p_hitem))\r
-          {\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the file '".$v_path.$p_hitem."'");\r
-\r
-            // ----- Add the file\r
-            if (($v_result = $this->privAddFile($v_path.$p_hitem, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)\r
-            {\r
-              // ----- Return status\r
-              //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-              return $v_result;\r
-            }\r
-\r
-            // ----- Store the file infos\r
-            $p_result_list[$v_nb++] = $v_header;\r
-          }\r
-\r
-          // ----- Recursive call to privAddFileList()\r
-          else\r
-          {\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the directory '".$v_path.$p_hitem."'");\r
-\r
-            // ----- Need an array as parameter\r
-            $p_temp_list[0] = $v_path.$p_hitem;\r
-            $v_result = $this->privAddFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);\r
-\r
-            // ----- Update the number of elements of the list\r
-            $v_nb = sizeof($p_result_list);\r
-          }\r
-        }\r
-\r
-        // ----- Free memory for the recursive loop\r
-        unset($p_temp_list);\r
-        unset($p_hdir);\r
-        unset($p_hitem);\r
-      }\r
-    }\r
-\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have $v_nb elements");\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privAddFile()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privAddFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='$p_filename', add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
-    $v_result=1;\r
-\r
-    if ($p_filename == "")\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Calculate the stored filename\r
-    $v_stored_filename = $p_filename;\r
-\r
-    // ----- Look for all path to remove\r
-    if ($p_remove_all_dir) {\r
-      $v_stored_filename = basename($p_filename);\r
-    }\r
-    // ----- Look for partial path remove\r
-    else if ($p_remove_dir != "")\r
-    {\r
-      if (substr($p_remove_dir, -1) != '/')\r
-        $p_remove_dir .= "/";\r
-\r
-      if ((substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./"))\r
-      {\r
-        if ((substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./"))\r
-          $p_remove_dir = "./".$p_remove_dir;\r
-        if ((substr($p_filename, 0, 2) != "./") && (substr($p_remove_dir, 0, 2) == "./"))\r
-          $p_remove_dir = substr($p_remove_dir, 2);\r
-      }\r
-\r
-      $v_compare = PclZipUtilPathInclusion($p_remove_dir, $p_filename);\r
-      if ($v_compare > 0)\r
-//      if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)\r
-      {\r
-\r
-        if ($v_compare == 2) {\r
-          $v_stored_filename = "";\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");\r
-        }\r
-        else {\r
-          $v_stored_filename = substr($p_filename, strlen($p_remove_dir));\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$p_filename' = '$v_stored_filename'");\r
-        }\r
-      }\r
-    }\r
-    // ----- Look for path to add\r
-    if ($p_add_dir != "")\r
-    {\r
-      if (substr($p_add_dir, -1) == "/")\r
-        $v_stored_filename = $p_add_dir.$v_stored_filename;\r
-      else\r
-        $v_stored_filename = $p_add_dir."/".$v_stored_filename;\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");\r
-    }\r
-\r
-    // ----- Filename (reduce the path of stored name)\r
-    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);\r
-\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Filename (reduced) '$v_stored_filename', strlen ".strlen($v_stored_filename));\r
-\r
-    /* filename length moved after call-back in release 1.3\r
-    // ----- Check the path length\r
-    if (strlen($v_stored_filename) > 0xFF)\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(-5, "Stored file name is too long (max. 255) : '$v_stored_filename'");\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-    */\r
-\r
-    // ----- Set the file properties\r
-    clearstatcache();\r
-    $p_header['version'] = 20;\r
-    $p_header['version_extracted'] = 10;\r
-    $p_header['flag'] = 0;\r
-    $p_header['compression'] = 0;\r
-    $p_header['mtime'] = filemtime($p_filename);\r
-    $p_header['crc'] = 0;\r
-    $p_header['compressed_size'] = 0;\r
-    $p_header['size'] = filesize($p_filename);\r
-    $p_header['filename_len'] = strlen($p_filename);\r
-    $p_header['extra_len'] = 0;\r
-    $p_header['comment_len'] = 0;\r
-    $p_header['disk'] = 0;\r
-    $p_header['internal'] = 0;\r
-    $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);\r
-    $p_header['offset'] = 0;\r
-    $p_header['filename'] = $p_filename;\r
-    $p_header['stored_filename'] = $v_stored_filename;\r
-    $p_header['extra'] = '';\r
-    $p_header['comment'] = '';\r
-    $p_header['status'] = 'ok';\r
-    $p_header['index'] = -1;\r
-\r
-    // ----- Look for pre-add callback\r
-    if (isset($p_options[PCLZIP_CB_PRE_ADD])) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");\r
-\r
-      // ----- Generate a local information\r
-      $v_local_header = array();\r
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);\r
-\r
-      // ----- Call the callback\r
-      // Here I do not use call_user_func() because I need to send a reference to the\r
-      // header.\r
-      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');\r
-      if ($v_result == 0) {\r
-        // ----- Change the file status\r
-        $p_header['status'] = "skipped";\r
-        $v_result = 1;\r
-      }\r
-\r
-      // ----- Update the informations\r
-      // Only some fields can be modified\r
-      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {\r
-        $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'");\r
-      }\r
-    }\r
-\r
-    // ----- Look for empty stored filename\r
-    if ($p_header['stored_filename'] == "") {\r
-      $p_header['status'] = "filtered";\r
-    }\r
-    \r
-    // ----- Check the path length\r
-    if (strlen($p_header['stored_filename']) > 0xFF) {\r
-      $p_header['status'] = 'filename_too_long';\r
-    }\r
-\r
-    // ----- Look if no error, or file not skipped\r
-    if ($p_header['status'] == 'ok') {\r
-\r
-      // ----- Look for a file\r
-      if (is_file($p_filename))\r
-      {\r
-        // ----- Open the source file\r
-        if (($v_file = @fopen($p_filename, "rb")) == 0) {\r
-          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-          return PclZip::errorCode();\r
-        }\r
-\r
-        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {\r
-          // ----- Read the file content\r
-          $v_content_compressed = @fread($v_file, $p_header['size']);\r
-\r
-          // ----- Calculate the CRC\r
-          $p_header['crc'] = crc32($v_content_compressed);\r
-        }\r
-        else {\r
-          // ----- Read the file content\r
-          $v_content = @fread($v_file, $p_header['size']);\r
-\r
-          // ----- Calculate the CRC\r
-          $p_header['crc'] = crc32($v_content);\r
-\r
-          // ----- Compress the file\r
-          $v_content_compressed = gzdeflate($v_content);\r
-        }\r
-\r
-        // ----- Set header parameters\r
-        $p_header['compressed_size'] = strlen($v_content_compressed);\r
-        $p_header['compression'] = 8;\r
-\r
-        // ----- Call the header generation\r
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {\r
-          @fclose($v_file);\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
-        }\r
-\r
-        // ----- Write the compressed content\r
-        $v_binary_data = pack('a'.$p_header['compressed_size'], $v_content_compressed);\r
-        @fwrite($this->zip_fd, $v_binary_data, $p_header['compressed_size']);\r
-        \r
-        // ----- Close the file\r
-        @fclose($v_file);\r
-      }\r
-\r
-      // ----- Look for a directory\r
-      else\r
-      {\r
-        // ----- Set the file properties\r
-        $p_header['filename'] .= '/';\r
-        $p_header['filename_len']++;\r
-        $p_header['size'] = 0;\r
-        $p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked\r
-\r
-        // ----- Call the header generation\r
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1)\r
-        {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
-        }\r
-      }\r
-    }\r
-\r
-    // ----- Look for pre-add callback\r
-    if (isset($p_options[PCLZIP_CB_POST_ADD])) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");\r
-\r
-      // ----- Generate a local information\r
-      $v_local_header = array();\r
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);\r
-\r
-      // ----- Call the callback\r
-      // Here I do not use call_user_func() because I need to send a reference to the\r
-      // header.\r
-      eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');\r
-      if ($v_result == 0) {\r
-        // ----- Ignored\r
-        $v_result = 1;\r
-      }\r
-\r
-      // ----- Update the informations\r
-      // Nothing can be modified\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privWriteFileHeader()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privWriteFileHeader(&$p_header)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');\r
-    $v_result=1;\r
-\r
-    // TBC\r
-    //for(reset($p_header); $key = key($p_header); next($p_header)) {\r
-    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);\r
-    //}\r
-\r
-    // ----- Store the offset position of the file\r
-    $p_header['offset'] = ftell($this->zip_fd);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);\r
-\r
-    // ----- Transform UNIX mtime to DOS format mdate/mtime\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
-    $v_date = getdate($p_header['mtime']);\r
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;\r
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];\r
-\r
-    // ----- Packed data\r
-    $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version'], $p_header['flag'],\r
-                          $p_header['compression'], $v_mtime, $v_mdate,\r
-                          $p_header['crc'], $p_header['compressed_size'], $p_header['size'],\r
-                          strlen($p_header['stored_filename']), $p_header['extra_len']);\r
-\r
-    // ----- Write the first 148 bytes of the header in the archive\r
-    fputs($this->zip_fd, $v_binary_data, 30);\r
-\r
-    // ----- Write the variable fields\r
-    if (strlen($p_header['stored_filename']) != 0)\r
-    {\r
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));\r
-    }\r
-    if ($p_header['extra_len'] != 0)\r
-    {\r
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privWriteCentralFileHeader()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privWriteCentralFileHeader(&$p_header)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');\r
-    $v_result=1;\r
-\r
-    // TBC\r
-    //for(reset($p_header); $key = key($p_header); next($p_header)) {\r
-    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);\r
-    //}\r
-\r
-    // ----- Transform UNIX mtime to DOS format mdate/mtime\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
-    $v_date = getdate($p_header['mtime']);\r
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;\r
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];\r
-\r
-    // ----- Packed data\r
-    $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'],\r
-                          $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'],\r
-                          $p_header['compressed_size'], $p_header['size'],\r
-                          strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'],\r
-                          $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']);\r
-\r
-    // ----- Write the 42 bytes of the header in the zip file\r
-    fputs($this->zip_fd, $v_binary_data, 46);\r
-\r
-    // ----- Write the variable fields\r
-    if (strlen($p_header['stored_filename']) != 0)\r
-    {\r
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));\r
-    }\r
-    if ($p_header['extra_len'] != 0)\r
-    {\r
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);\r
-    }\r
-    if ($p_header['comment_len'] != 0)\r
-    {\r
-      fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privWriteCentralHeader()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"');\r
-    $v_result=1;\r
-\r
-    // ----- Packed data\r
-    $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment));\r
-\r
-    // ----- Write the 22 bytes of the header in the zip file\r
-    fputs($this->zip_fd, $v_binary_data, 22);\r
-\r
-    // ----- Write the variable fields\r
-    if (strlen($p_comment) != 0)\r
-    {\r
-      fputs($this->zip_fd, $p_comment, strlen($p_comment));\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privList()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privList(&$p_list)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");\r
-    $v_result=1;\r
-\r
-    // ----- Open the zip file\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-    if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Read the central directory informations\r
-    $v_central_dir = array();\r
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Go to beginning of Central Dir\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");\r
-    @rewind($this->zip_fd);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");\r
-    if (@fseek($this->zip_fd, $v_central_dir['offset']))\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");\r
-\r
-    // ----- Read each entry\r
-    for ($i=0; $i<$v_central_dir['entries']; $i++)\r
-    {\r
-      // ----- Read the file header\r
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        return $v_result;\r
-      }\r
-      $v_header['index'] = $i;\r
-\r
-      // ----- Get the only interesting attributes\r
-      $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);\r
-      unset($v_header);\r
-    }\r
-\r
-    // ----- Close the zip file\r
-    $this->privCloseFd();\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privConvertHeader2FileInfo()\r
-  // Description :\r
-  //   This function takes the file informations from the central directory\r
-  //   entries and extract the interesting parameters that will be given back.\r
-  //   The resulting file infos are set in the array $p_info\r
-  //     $p_info['filename'] : Filename with full path. Given by user (add),\r
-  //                           extracted in the filesystem (extract).\r
-  //     $p_info['stored_filename'] : Stored filename in the archive.\r
-  //     $p_info['size'] = Size of the file.\r
-  //     $p_info['compressed_size'] = Compressed size of the file.\r
-  //     $p_info['mtime'] = Last modification date of the file.\r
-  //     $p_info['comment'] = Comment associated with the file.\r
-  //     $p_info['folder'] = true/false : indicates if the entry is a folder or not.\r
-  //     $p_info['status'] = status of the action on the file.\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privConvertHeader2FileInfo($p_header, &$p_info)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");\r
-    $v_result=1;\r
-\r
-    // ----- Get the interesting attributes\r
-    $p_info['filename'] = $p_header['filename'];\r
-    $p_info['stored_filename'] = $p_header['stored_filename'];\r
-    $p_info['size'] = $p_header['size'];\r
-    $p_info['compressed_size'] = $p_header['compressed_size'];\r
-    $p_info['mtime'] = $p_header['mtime'];\r
-    $p_info['comment'] = $p_header['comment'];\r
-    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);\r
-    $p_info['index'] = $p_header['index'];\r
-    $p_info['status'] = $p_header['status'];\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privExtractByRule()\r
-  // Description :\r
-  //   Extract a file or directory depending of rules (by index, by name, ...)\r
-  // Parameters :\r
-  //   $p_file_list : An array where will be placed the properties of each\r
-  //                  extracted file\r
-  //   $p_path : Path to add while writing the extracted files\r
-  //   $p_remove_path : Path to remove (from the file memorized path) while writing the\r
-  //                    extracted files. If the path does not match the file path,\r
-  //                    the file is extracted with its memorized path.\r
-  //                    $p_remove_path does not apply to 'list' mode.\r
-  //                    $p_path and $p_remove_path are commulative.\r
-  // Return Values :\r
-  //   1 on success,0 or less on error (see error code list)\r
-  // --------------------------------------------------------------------------------\r
-  function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");\r
-    $v_result=1;\r
-\r
-    // ----- Check the path\r
-    if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../") && (substr($p_path,1,1)!=":")))\r
-      $p_path = "./".$p_path;\r
-\r
-    // ----- Reduce the path last (and duplicated) '/'\r
-    if (($p_path != "./") && ($p_path != "/"))\r
-    {\r
-      // ----- Look for the path end '/'\r
-      while (substr($p_path, -1) == "/")\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");\r
-        $p_path = substr($p_path, 0, strlen($p_path)-1);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");\r
-      }\r
-    }\r
-\r
-    // ----- Look for path to remove format (should end by /)\r
-    if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))\r
-    {\r
-      $p_remove_path .= '/';\r
-    }\r
-    $p_remove_path_size = strlen($p_remove_path);\r
-\r
-    // ----- Open the zip file\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-    if (($v_result = $this->privOpenFd('rb')) != 1)\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Read the central directory informations\r
-    $v_central_dir = array();\r
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
-    {\r
-      // ----- Close the zip file\r
-      $this->privCloseFd();\r
-\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Start at beginning of Central Dir\r
-    $v_pos_entry = $v_central_dir['offset'];\r
-\r
-    // ----- Read each entry\r
-    $j_start = 0;\r
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'");\r
-\r
-      // ----- Read next Central dir entry\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'");\r
-      @rewind($this->zip_fd);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'");\r
-      if (@fseek($this->zip_fd, $v_pos_entry))\r
-      {\r
-        // ----- Close the zip file\r
-        $this->privCloseFd();\r
-\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");\r
-\r
-      // ----- Read the file header\r
-      $v_header = array();\r
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)\r
-      {\r
-        // ----- Close the zip file\r
-        $this->privCloseFd();\r
-\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        return $v_result;\r
-      }\r
-\r
-      // ----- Store the index\r
-      $v_header['index'] = $i;\r
-\r
-      // ----- Store the file position\r
-      $v_pos_entry = ftell($this->zip_fd);\r
-\r
-      // ----- Look for the specific extract rules\r
-      $v_extract = false;\r
-\r
-      // ----- Look for extract by name rule\r
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))\r
-          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");\r
-\r
-          // ----- Look if the filename is in the list\r
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");\r
-\r
-              // ----- Look for a directory\r
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");\r
-\r
-                  // ----- Look if the directory is in the filename path\r
-                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))\r
-                      && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {\r
-                      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");\r
-                      $v_extract = true;\r
-                  }\r
-              }\r
-              // ----- Look for a filename\r
-              elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");\r
-                  $v_extract = true;\r
-              }\r
-          }\r
-      }\r
-\r
-      // ----- Look for extract by ereg rule\r
-      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))\r
-               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");\r
-\r
-          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");\r
-              $v_extract = true;\r
-          }\r
-      }\r
-\r
-      // ----- Look for extract by preg rule\r
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))\r
-               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");\r
-\r
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");\r
-              $v_extract = true;\r
-          }\r
-      }\r
-\r
-      // ----- Look for extract by index rule\r
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))\r
-               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");\r
-          \r
-          // ----- Look if the index is in the list\r
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");\r
-\r
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");\r
-                  $v_extract = true;\r
-              }\r
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");\r
-                  $j_start = $j+1;\r
-              }\r
-\r
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");\r
-                  break;\r
-              }\r
-          }\r
-      }\r
-\r
-      // ----- Look for no rule, which means extract all the archive\r
-      else {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)");\r
-          $v_extract = true;\r
-      }\r
-      \r
-\r
-      // ----- Look for real extraction\r
-      if ($v_extract)\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");\r
-\r
-        // ----- Go to the file position\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");\r
-        @rewind($this->zip_fd);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");\r
-        if (@fseek($this->zip_fd, $v_header['offset']))\r
-        {\r
-          // ----- Close the zip file\r
-          $this->privCloseFd();\r
-\r
-          // ----- Error log\r
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
-\r
-          // ----- Return\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-          return PclZip::errorCode();\r
-        }\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");\r
-\r
-        // ----- Look for extraction as string\r
-        if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {\r
-\r
-          // ----- Extracting the file\r
-          if (($v_result = $this->privExtractFileAsString($v_header, $v_string)) != 1)\r
-          {\r
-            // ----- Close the zip file\r
-            $this->privCloseFd();\r
-\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-            return $v_result;\r
-          }\r
-\r
-          // ----- Get the only interesting attributes\r
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)\r
-          {\r
-            // ----- Close the zip file\r
-            $this->privCloseFd();\r
-\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-            return $v_result;\r
-          }\r
-\r
-          // ----- Set the file content\r
-          $p_file_list[$v_nb_extracted]['content'] = $v_string;\r
-\r
-          // ----- Next extracted file\r
-          $v_nb_extracted++;\r
-        }\r
-        else {\r
-          // ----- Extracting the file\r
-          if (($v_result = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options)) != 1)\r
-          {\r
-            // ----- Close the zip file\r
-            $this->privCloseFd();\r
-\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-            return $v_result;\r
-          }\r
-\r
-          // ----- Get the only interesting attributes\r
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)\r
-          {\r
-            // ----- Close the zip file\r
-            $this->privCloseFd();\r
-\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-            return $v_result;\r
-          }\r
-        }\r
-      }\r
-    }\r
-\r
-    // ----- Close the zip file\r
-    $this->privCloseFd();\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privExtractFile()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");\r
-    $v_result=1;\r
-\r
-    // ----- Read the file header\r
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");\r
-\r
-    // ----- Check that the file header is coherent with $p_entry info\r
-    // TBC\r
-\r
-    // ----- Look for all path to remove\r
-    if ($p_remove_all_path == true) {\r
-        // ----- Get the basename of the path\r
-        $p_entry['filename'] = basename($p_entry['filename']);\r
-    }\r
-\r
-    // ----- Look for path to remove\r
-    else if ($p_remove_path != "")\r
-    {\r
-      //if (strcmp($p_remove_path, $p_entry['filename'])==0)\r
-      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");\r
-\r
-        // ----- Change the file status\r
-        $p_entry['status'] = "filtered";\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        return $v_result;\r
-      }\r
-\r
-      $p_remove_path_size = strlen($p_remove_path);\r
-      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");\r
-\r
-        // ----- Remove the path\r
-        $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);\r
-\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");\r
-      }\r
-    }\r
-\r
-    // ----- Add the path\r
-    if ($p_path != '')\r
-    {\r
-      $p_entry['filename'] = $p_path."/".$p_entry['filename'];\r
-    }\r
-\r
-    // ----- Look for pre-extract callback\r
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");\r
-\r
-      // ----- Generate a local information\r
-      $v_local_header = array();\r
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);\r
-\r
-      // ----- Call the callback\r
-      // Here I do not use call_user_func() because I need to send a reference to the\r
-      // header.\r
-      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');\r
-      if ($v_result == 0) {\r
-        // ----- Change the file status\r
-        $p_entry['status'] = "skipped";\r
-        $v_result = 1;\r
-      }\r
-\r
-      // ----- Update the informations\r
-      // Only some fields can be modified\r
-      $p_entry['filename'] = $v_local_header['filename'];\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");\r
-    }\r
-\r
-    // ----- Trace\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");\r
-\r
-    // ----- Look if extraction should be done\r
-    if ($p_entry['status'] == 'ok') {\r
-\r
-    // ----- Look for specific actions while the file exist\r
-    if (file_exists($p_entry['filename']))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");\r
-\r
-      // ----- Look if file is a directory\r
-      if (is_dir($p_entry['filename']))\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");\r
-\r
-        // ----- Change the file status\r
-        $p_entry['status'] = "already_a_directory";\r
-\r
-        // ----- Return\r
-        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        //return $v_result;\r
-      }\r
-      // ----- Look if file is write protected\r
-      else if (!is_writeable($p_entry['filename']))\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");\r
-\r
-        // ----- Change the file status\r
-        $p_entry['status'] = "write_protected";\r
-\r
-        // ----- Return\r
-        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        //return $v_result;\r
-      }\r
-\r
-      // ----- Look if the extracted file is older\r
-      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");\r
-\r
-        // ----- Change the file status\r
-        $p_entry['status'] = "newer_exist";\r
-\r
-        // ----- Return\r
-        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        //return $v_result;\r
-      }\r
-    }\r
-\r
-    // ----- Check the directory availability and create it if necessary\r
-    else {\r
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))\r
-        $v_dir_to_check = $p_entry['filename'];\r
-      else if (!strstr($p_entry['filename'], "/"))\r
-        $v_dir_to_check = "";\r
-      else\r
-        $v_dir_to_check = dirname($p_entry['filename']);\r
-\r
-      if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");\r
-\r
-        // ----- Change the file status\r
-        $p_entry['status'] = "path_creation_fail";\r
-\r
-        // ----- Return\r
-        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        //return $v_result;\r
-        $v_result = 1;\r
-      }\r
-    }\r
-    }\r
-\r
-    // ----- Look if extraction should be done\r
-    if ($p_entry['status'] == 'ok') {\r
-\r
-      // ----- Do the extraction (if not a folder)\r
-      if (!(($p_entry['external']&0x00000010)==0x00000010))\r
-      {\r
-\r
-        // ----- Look for not compressed file\r
-        if ($p_entry['compressed_size'] == $p_entry['size'])\r
-        {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");\r
-\r
-          // ----- Opening destination file\r
-          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)\r
-          {\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
-\r
-            // ----- Change the file status\r
-            $p_entry['status'] = "write_error";\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-            return $v_result;\r
-          }\r
-\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");\r
-\r
-          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
-          $v_size = $p_entry['compressed_size'];\r
-          while ($v_size != 0)\r
-          {\r
-            $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
-            $v_buffer = fread($this->zip_fd, $v_read_size);\r
-            $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
-            @fwrite($v_dest_file, $v_binary_data, $v_read_size);\r
-            $v_size -= $v_read_size;\r
-          }\r
-\r
-          // ----- Closing the destination file\r
-          fclose($v_dest_file);\r
-\r
-          // ----- Change the file mtime\r
-          touch($p_entry['filename'], $p_entry['mtime']);\r
-        }\r
-        else\r
-        {\r
-          // ----- Trace\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");\r
-\r
-          // ----- Opening destination file\r
-          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
-\r
-            // ----- Change the file status\r
-            $p_entry['status'] = "write_error";\r
-\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-            return $v_result;\r
-          }\r
-\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");\r
-\r
-          // ----- Read the compressed file in a buffer (one shot)\r
-          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);\r
-          \r
-          // ----- Decompress the file\r
-          $v_file_content = gzinflate($v_buffer);\r
-          unset($v_buffer);\r
-\r
-          // ----- Write the uncompressed data\r
-          @fwrite($v_dest_file, $v_file_content, $p_entry['size']);\r
-          unset($v_file_content);\r
-\r
-          // ----- Closing the destination file\r
-          @fclose($v_dest_file);\r
-\r
-          // ----- Change the file mtime\r
-          touch($p_entry['filename'], $p_entry['mtime']);\r
-        }\r
-\r
-        // ----- Look for chmod option\r
-        if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");\r
-\r
-          // ----- Change the mode of the file\r
-          chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);\r
-        }\r
-\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");\r
-      }\r
-    }\r
-\r
-    // ----- Look for post-extract callback\r
-    if (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");\r
-\r
-      // ----- Generate a local information\r
-      $v_local_header = array();\r
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);\r
-\r
-      // ----- Call the callback\r
-      // Here I do not use call_user_func() because I need to send a reference to the\r
-      // header.\r
-      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privExtractFileAsString()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privExtractFileAsString(&$p_entry, &$p_string)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");\r
-    $v_result=1;\r
-\r
-    // ----- Read the file header\r
-    $v_header = array();\r
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");\r
-\r
-    // ----- Check that the file header is coherent with $p_entry info\r
-    // TBC\r
-\r
-    // ----- Trace\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'");\r
-\r
-    // ----- Do the extraction (if not a folder)\r
-    if (!(($p_entry['external']&0x00000010)==0x00000010))\r
-    {\r
-      // ----- Look for not compressed file\r
-      if ($p_entry['compressed_size'] == $p_entry['size'])\r
-      {\r
-        // ----- Trace\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");\r
-\r
-        // ----- Reading the file\r
-        $p_string = fread($this->zip_fd, $p_entry['compressed_size']);\r
-      }\r
-      else\r
-      {\r
-        // ----- Trace\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");\r
-\r
-        // ----- Reading the file\r
-        $v_data = fread($this->zip_fd, $p_entry['compressed_size']);\r
-        \r
-        // ----- Decompress the file\r
-        $p_string = gzinflate($v_data);\r
-      }\r
-\r
-      // ----- Trace\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");\r
-    }\r
-    else {\r
-        // TBC : error : can not extract a folder in a string\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privReadFileHeader()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privReadFileHeader(&$p_header)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");\r
-    $v_result=1;\r
-\r
-    // ----- Read the 4 bytes signature\r
-    $v_binary_data = @fread($this->zip_fd, 4);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");\r
-    $v_data = unpack('Vid', $v_binary_data);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");\r
-\r
-    // ----- Check signature\r
-    if ($v_data['id'] != 0x04034b50)\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");\r
-\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Read the first 42 bytes of the header\r
-    $v_binary_data = fread($this->zip_fd, 26);\r
-\r
-    // ----- Look for invalid block size\r
-    if (strlen($v_binary_data) != 26)\r
-    {\r
-      $p_header['filename'] = "";\r
-      $p_header['status'] = "invalid_header";\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));\r
-\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Extract the values\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");\r
-    $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);\r
-\r
-    // ----- Get filename\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);\r
-    $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');\r
-\r
-    // ----- Get extra_fields\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);\r
-    if ($v_data['extra_len'] != 0) {\r
-      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);\r
-    }\r
-    else {\r
-      $p_header['extra'] = '';\r
-    }\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');\r
-\r
-    // ----- Extract properties\r
-    $p_header['compression'] = $v_data['compression'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.bin2hex($p_header['compression']).'\'');\r
-    $p_header['size'] = $v_data['size'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');\r
-    $p_header['compressed_size'] = $v_data['compressed_size'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');\r
-    $p_header['crc'] = $v_data['crc'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.$p_header['crc'].'\'');\r
-    $p_header['flag'] = $v_data['flag'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');\r
-\r
-    // ----- Recuperate date in UNIX format\r
-    $p_header['mdate'] = $v_data['mdate'];\r
-    $p_header['mtime'] = $v_data['mtime'];\r
-    if ($p_header['mdate'] && $p_header['mtime'])\r
-    {\r
-      // ----- Extract time\r
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;\r
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;\r
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;\r
-\r
-      // ----- Extract date\r
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;\r
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;\r
-      $v_day = $p_header['mdate'] & 0x001F;\r
-\r
-      // ----- Get UNIX date format\r
-      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);\r
-\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
-    }\r
-    else\r
-    {\r
-      $p_header['mtime'] = time();\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
-    }\r
-\r
-    // ----- Other informations\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compression type : ".$v_data['compression']);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Version : ".$v_data['version']);\r
-\r
-    // TBC\r
-    //for(reset($v_data); $key = key($v_data); next($v_data)) {\r
-    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);\r
-    //}\r
-\r
-    // ----- Set the stored filename\r
-    $p_header['stored_filename'] = $p_header['filename'];\r
-\r
-    // ----- Set the status field\r
-    $p_header['status'] = "ok";\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privReadCentralFileHeader()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privReadCentralFileHeader(&$p_header)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");\r
-    $v_result=1;\r
-\r
-    // ----- Read the 4 bytes signature\r
-    $v_binary_data = @fread($this->zip_fd, 4);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");\r
-    $v_data = unpack('Vid', $v_binary_data);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");\r
-\r
-    // ----- Check signature\r
-    if ($v_data['id'] != 0x02014b50)\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");\r
-\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Read the first 42 bytes of the header\r
-    $v_binary_data = fread($this->zip_fd, 42);\r
-\r
-    // ----- Look for invalid block size\r
-    if (strlen($v_binary_data) != 42)\r
-    {\r
-      $p_header['filename'] = "";\r
-      $p_header['status'] = "invalid_header";\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));\r
-\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Extract the values\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'");\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'");\r
-    $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);\r
-\r
-    // ----- Get filename\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']);\r
-    if ($p_header['filename_len'] != 0)\r
-      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);\r
-    else\r
-      $p_header['filename'] = '';\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\'');\r
-\r
-    // ----- Get extra\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']);\r
-    if ($p_header['extra_len'] != 0)\r
-      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);\r
-    else\r
-      $p_header['extra'] = '';\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\'');\r
-\r
-    // ----- Get comment\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']);\r
-    if ($p_header['comment_len'] != 0)\r
-      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);\r
-    else\r
-      $p_header['comment'] = '';\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\'');\r
-\r
-    // ----- Extract properties\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\'');\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\'');\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\'');\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.$p_header['crc'].'\'');\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\'');\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\'');\r
-\r
-    // ----- Recuperate date in UNIX format\r
-    if ($p_header['mdate'] && $p_header['mtime'])\r
-    {\r
-      // ----- Extract time\r
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;\r
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;\r
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;\r
-\r
-      // ----- Extract date\r
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;\r
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;\r
-      $v_day = $p_header['mdate'] & 0x001F;\r
-\r
-      // ----- Get UNIX date format\r
-      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);\r
-\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
-    }\r
-    else\r
-    {\r
-      $p_header['mtime'] = time();\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
-    }\r
-\r
-    // ----- Set the stored filename\r
-    $p_header['stored_filename'] = $p_header['filename'];\r
-\r
-    // ----- Set default status to ok\r
-    $p_header['status'] = 'ok';\r
-\r
-    // ----- Look if it is a directory\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'");\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')');\r
-    if (substr($p_header['filename'], -1) == '/')\r
-    {\r
-      $p_header['external'] = 0x41FF0010;\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.$p_header['external'].'\'');\r
-    }\r
-\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\'');\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privReadEndCentralDir()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privReadEndCentralDir(&$p_central_dir)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");\r
-    $v_result=1;\r
-\r
-    // ----- Go to the end of the zip file\r
-    $v_size = filesize($this->zipname);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");\r
-    @fseek($this->zip_fd, $v_size);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');\r
-    if (@ftell($this->zip_fd) != $v_size)\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- First try : look if this is an archive with no commentaries (most of the time)\r
-    // in this case the end of central dir is at 22 bytes of the file end\r
-    $v_found = 0;\r
-    if ($v_size > 26) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');\r
-      @fseek($this->zip_fd, $v_size-22);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');\r
-      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))\r
-      {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
-\r
-      // ----- Read for bytes\r
-      $v_binary_data = @fread($this->zip_fd, 4);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");\r
-      $v_data = unpack('Vid', $v_binary_data);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");\r
-\r
-      // ----- Check signature\r
-      if ($v_data['id'] == 0x06054b50) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");\r
-        $v_found = 1;\r
-      }\r
-\r
-      $v_pos = ftell($this->zip_fd);\r
-    }\r
-\r
-    // ----- Go back to the maximum possible size of the Central Dir End Record\r
-    if (!$v_found) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');\r
-      $v_maximum_size = 65557; // 0xFFFF + 22;\r
-      if ($v_maximum_size > $v_size)\r
-        $v_maximum_size = $v_size;\r
-      @fseek($this->zip_fd, $v_size-$v_maximum_size);\r
-      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))\r
-      {\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');\r
-\r
-      // ----- Read byte per byte in order to find the signature\r
-      $v_pos = ftell($this->zip_fd);\r
-      $v_bytes = 0x00000000;\r
-      while ($v_pos < $v_size)\r
-      {\r
-        // ----- Read a byte\r
-        $v_byte = @fread($this->zip_fd, 1);\r
-\r
-        // -----  Add the byte\r
-        $v_bytes = ($v_bytes << 8) | Ord($v_byte);\r
-\r
-        // ----- Compare the bytes\r
-        if ($v_bytes == 0x504b0506)\r
-        {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');\r
-          $v_pos++;\r
-          break;\r
-        }\r
-\r
-        $v_pos++;\r
-      }\r
-\r
-      // ----- Look if not found end of central dir\r
-      if ($v_pos == $v_size)\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");\r
-\r
-        // ----- Error log\r
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");\r
-\r
-        // ----- Return\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-        return PclZip::errorCode();\r
-      }\r
-    }\r
-\r
-    // ----- Read the first 18 bytes of the header\r
-    $v_binary_data = fread($this->zip_fd, 18);\r
-\r
-    // ----- Look for invalid block size\r
-    if (strlen($v_binary_data) != 18)\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));\r
-\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Extract the values\r
-    ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");\r
-    ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");\r
-    $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);\r
-\r
-    // ----- Check the global size\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);\r
-    if (($v_pos + $v_data['comment_size'] + 18) != $v_size)\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Fail to find the right signature");\r
-\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Fail to find the right signature");\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Get comment\r
-    if ($v_data['comment_size'] != 0)\r
-      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);\r
-    else\r
-      $p_central_dir['comment'] = '';\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');\r
-\r
-    $p_central_dir['entries'] = $v_data['entries'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');\r
-    $p_central_dir['disk_entries'] = $v_data['disk_entries'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');\r
-    $p_central_dir['offset'] = $v_data['offset'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');\r
-    $p_central_dir['size'] = $v_data['size'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');\r
-    $p_central_dir['disk'] = $v_data['disk'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');\r
-    $p_central_dir['disk_start'] = $v_data['disk_start'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');\r
-\r
-    // TBC\r
-    //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {\r
-    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);\r
-    //}\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privDeleteByRule()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privDeleteByRule(&$p_result_list, &$p_options)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");\r
-    $v_result=1;\r
-    $v_list_detail = array();\r
-\r
-    // ----- Open the zip file\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-    if (($v_result=$this->privOpenFd('rb')) != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Read the central directory informations\r
-    $v_central_dir = array();\r
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
-    {\r
-      $this->privCloseFd();\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Go to beginning of File\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");\r
-    @rewind($this->zip_fd);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");\r
-\r
-    // ----- Scan all the files\r
-    // ----- Start at beginning of Central Dir\r
-    $v_pos_entry = $v_central_dir['offset'];\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");\r
-    @rewind($this->zip_fd);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");\r
-    if (@fseek($this->zip_fd, $v_pos_entry))\r
-    {\r
-      // ----- Close the zip file\r
-      $this->privCloseFd();\r
-\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");\r
-\r
-    // ----- Read each entry\r
-    $v_header_list = array();\r
-    $j_start = 0;\r
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')");\r
-\r
-      // ----- Read the file header\r
-      $v_header_list[$v_nb_extracted] = array();\r
-      if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)\r
-      {\r
-        // ----- Close the zip file\r
-        $this->privCloseFd();\r
-\r
-        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-        return $v_result;\r
-      }\r
-\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");\r
-\r
-      // ----- Store the index\r
-      $v_header_list[$v_nb_extracted]['index'] = $i;\r
-\r
-      // ----- Look for the specific extract rules\r
-      $v_found = false;\r
-\r
-      // ----- Look for extract by name rule\r
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))\r
-          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");\r
-\r
-          // ----- Look if the filename is in the list\r
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");\r
-\r
-              // ----- Look for a directory\r
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");\r
-\r
-                  // ----- Look if the directory is in the filename path\r
-                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))\r
-                      && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {\r
-                      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");\r
-                      $v_found = true;\r
-                  }\r
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */\r
-                          && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {\r
-                      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");\r
-                      $v_found = true;\r
-                  }\r
-              }\r
-              // ----- Look for a filename\r
-              elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");\r
-                  $v_found = true;\r
-              }\r
-          }\r
-      }\r
-\r
-      // ----- Look for extract by ereg rule\r
-      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))\r
-               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");\r
-\r
-          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");\r
-              $v_found = true;\r
-          }\r
-      }\r
-\r
-      // ----- Look for extract by preg rule\r
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))\r
-               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");\r
-\r
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");\r
-              $v_found = true;\r
-          }\r
-      }\r
-\r
-      // ----- Look for extract by index rule\r
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))\r
-               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");\r
-\r
-          // ----- Look if the index is in the list\r
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {\r
-              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");\r
-\r
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");\r
-                  $v_found = true;\r
-              }\r
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");\r
-                  $j_start = $j+1;\r
-              }\r
-\r
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {\r
-                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");\r
-                  break;\r
-              }\r
-          }\r
-      }\r
-\r
-      // ----- Look for deletion\r
-      if ($v_found)\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted");\r
-        unset($v_header_list[$v_nb_extracted]);\r
-      }\r
-      else\r
-      {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted");\r
-        $v_nb_extracted++;\r
-      }\r
-    }\r
-\r
-    // ----- Look if something need to be deleted\r
-    if ($v_nb_extracted > 0) {\r
-\r
-        // ----- Creates a temporay file\r
-        $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';\r
-\r
-        // ----- Creates a temporary zip archive\r
-        $v_temp_zip = new PclZip($v_zip_temp_name);\r
-\r
-        // ----- Open the temporary zip file in write mode\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");\r
-        if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {\r
-            $this->privCloseFd();\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-            return $v_result;\r
-        }\r
-\r
-        // ----- Look which file need to be kept\r
-        for ($i=0; $i<sizeof($v_header_list); $i++) {\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'");\r
-\r
-            // ----- Calculate the position of the header\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'");\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");\r
-            @rewind($this->zip_fd);\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");\r
-            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {\r
-                // ----- Close the zip file\r
-                $this->privCloseFd();\r
-                $v_temp_zip->privCloseFd();\r
-                @unlink($v_zip_temp_name);\r
-\r
-                // ----- Error log\r
-                PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
-\r
-                // ----- Return\r
-                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-                return PclZip::errorCode();\r
-            }\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");\r
-\r
-            // ----- Read the file header\r
-            if (($v_result = $this->privReadFileHeader($v_header_list[$i])) != 1) {\r
-                // ----- Close the zip file\r
-                $this->privCloseFd();\r
-                $v_temp_zip->privCloseFd();\r
-                @unlink($v_zip_temp_name);\r
-\r
-                // ----- Return\r
-                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-                return $v_result;\r
-            }\r
-\r
-            // ----- Write the file header\r
-            if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {\r
-                // ----- Close the zip file\r
-                $this->privCloseFd();\r
-                $v_temp_zip->privCloseFd();\r
-                @unlink($v_zip_temp_name);\r
-\r
-                // ----- Return\r
-                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-                return $v_result;\r
-            }\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'");\r
-\r
-            // ----- Read/write the data block\r
-            if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {\r
-                // ----- Close the zip file\r
-                $this->privCloseFd();\r
-                $v_temp_zip->privCloseFd();\r
-                @unlink($v_zip_temp_name);\r
-\r
-                // ----- Return\r
-                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-                return $v_result;\r
-            }\r
-        }\r
-\r
-        // ----- Store the offset of the central dir\r
-        $v_offset = @ftell($v_temp_zip->zip_fd);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset");\r
-\r
-        // ----- Re-Create the Central Dir files header\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory");\r
-        for ($i=0; $i<sizeof($v_header_list); $i++) {\r
-            // ----- Create the file header\r
-            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']);\r
-            if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {\r
-                $v_temp_zip->privCloseFd();\r
-                $this->privCloseFd();\r
-                @unlink($v_zip_temp_name);\r
-\r
-                // ----- Return\r
-                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-                return $v_result;\r
-            }\r
-\r
-            // ----- Transform the header to a 'usable' info\r
-            $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);\r
-        }\r
-\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer");\r
-\r
-        // ----- Zip file comment\r
-        $v_comment = '';\r
-\r
-        // ----- Calculate the size of the central header\r
-        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;\r
-\r
-        // ----- Create the central dir footer\r
-        if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {\r
-            // ----- Reset the file list\r
-            unset($v_header_list);\r
-            $v_temp_zip->privCloseFd();\r
-            $this->privCloseFd();\r
-            @unlink($v_zip_temp_name);\r
-\r
-            // ----- Return\r
-            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-            return $v_result;\r
-        }\r
-\r
-        // ----- Close\r
-        $v_temp_zip->privCloseFd();\r
-        $this->privCloseFd();\r
-\r
-        // ----- Delete the zip file\r
-        // TBC : I should test the result ...\r
-        @unlink($this->zipname);\r
-\r
-        // ----- Rename the temporary file\r
-        // TBC : I should test the result ...\r
-        //@rename($v_zip_temp_name, $this->zipname);\r
-        PclZipUtilRename($v_zip_temp_name, $this->zipname);\r
-    \r
-        // ----- Destroy the temporary archive\r
-        unset($v_temp_zip);\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privDirCheck()\r
-  // Description :\r
-  //   Check if a directory exists, if not it creates it and all the parents directory\r
-  //   which may be useful.\r
-  // Parameters :\r
-  //   $p_dir : Directory path to check.\r
-  // Return Values :\r
-  //    1 : OK\r
-  //   -1 : Unable to create directory\r
-  // --------------------------------------------------------------------------------\r
-  function privDirCheck($p_dir, $p_is_dir=false)\r
-  {\r
-    $v_result = 1;\r
-\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");\r
-\r
-    // ----- Remove the final '/'\r
-    if (($p_is_dir) && (substr($p_dir, -1)=='/'))\r
-    {\r
-      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);\r
-    }\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");\r
-\r
-    // ----- Check the directory availability\r
-    if ((is_dir($p_dir)) || ($p_dir == ""))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");\r
-      return 1;\r
-    }\r
-\r
-    // ----- Extract parent directory\r
-    $p_parent_dir = dirname($p_dir);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");\r
-\r
-    // ----- Just a check\r
-    if ($p_parent_dir != $p_dir)\r
-    {\r
-      // ----- Look for parent directory\r
-      if ($p_parent_dir != "")\r
-      {\r
-        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)\r
-        {\r
-          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-          return $v_result;\r
-        }\r
-      }\r
-    }\r
-\r
-    // ----- Create the directory\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");\r
-    if (!@mkdir($p_dir, 0777))\r
-    {\r
-      // ----- Error log\r
-      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privMerge()\r
-  // Description :\r
-  //   If $p_archive_to_add does not exist, the function exit with a success result.\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privMerge(&$p_archive_to_add)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");\r
-    $v_result=1;\r
-\r
-    // ----- Look if the archive_to_add exists\r
-    if (!is_file($p_archive_to_add->zipname))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");\r
-\r
-      // ----- Nothing to merge, so merge is a success\r
-      $v_result = 1;\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Look if the archive exists\r
-    if (!is_file($this->zipname))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");\r
-\r
-      // ----- Do a duplicate\r
-      $v_result = $this->privDuplicate($p_archive_to_add->zipname);\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Open the zip file\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-    if (($v_result=$this->privOpenFd('rb')) != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Read the central directory informations\r
-    $v_central_dir = array();\r
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
-    {\r
-      $this->privCloseFd();\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Go to beginning of File\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");\r
-    @rewind($this->zip_fd);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");\r
-\r
-    // ----- Open the archive_to_add file\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");\r
-    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)\r
-    {\r
-      $this->privCloseFd();\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Read the central directory informations\r
-    $v_central_dir_to_add = array();\r
-    if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)\r
-    {\r
-      $this->privCloseFd();\r
-      $p_archive_to_add->privCloseFd();\r
-\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Go to beginning of File\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");\r
-    @rewind($p_archive_to_add->zip_fd);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");\r
-\r
-    // ----- Creates a temporay file\r
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';\r
-\r
-    // ----- Open the temporary file in write mode\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)\r
-    {\r
-      $this->privCloseFd();\r
-      $p_archive_to_add->privCloseFd();\r
-\r
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Copy the files from the archive to the temporary file\r
-    // TBC : Here I should better append the file and go back to erase the central dir\r
-    $v_size = $v_central_dir['offset'];\r
-    while ($v_size != 0)\r
-    {\r
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-      $v_buffer = fread($this->zip_fd, $v_read_size);\r
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
-      $v_size -= $v_read_size;\r
-    }\r
-\r
-    // ----- Copy the files from the archive_to_add into the temporary file\r
-    $v_size = $v_central_dir_to_add['offset'];\r
-    while ($v_size != 0)\r
-    {\r
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);\r
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
-      $v_size -= $v_read_size;\r
-    }\r
-\r
-    // ----- Store the offset of the central dir\r
-    $v_offset = @ftell($v_zip_temp_fd);\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");\r
-\r
-    // ----- Copy the block of file headers from the old archive\r
-    $v_size = $v_central_dir['size'];\r
-    while ($v_size != 0)\r
-    {\r
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-      $v_buffer = @fread($this->zip_fd, $v_read_size);\r
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
-      $v_size -= $v_read_size;\r
-    }\r
-\r
-    // ----- Copy the block of file headers from the archive_to_add\r
-    $v_size = $v_central_dir_to_add['size'];\r
-    while ($v_size != 0)\r
-    {\r
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);\r
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
-      $v_size -= $v_read_size;\r
-    }\r
-\r
-    // ----- Zip file comment\r
-    // TBC : I should merge the two comments\r
-    $v_comment = '';\r
-\r
-    // ----- Calculate the size of the (new) central header\r
-    $v_size = @ftell($v_zip_temp_fd)-$v_offset;\r
-\r
-    // ----- Swap the file descriptor\r
-    // Here is a trick : I swap the temporary fd with the zip fd, in order to use\r
-    // the following methods on the temporary fil and not the real archive fd\r
-    $v_swap = $this->zip_fd;\r
-    $this->zip_fd = $v_zip_temp_fd;\r
-    $v_zip_temp_fd = $v_swap;\r
-\r
-    // ----- Create the central dir footer\r
-    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)\r
-    {\r
-      $this->privCloseFd();\r
-      $p_archive_to_add->privCloseFd();\r
-      @fclose($v_zip_temp_fd);\r
-      $this->zip_fd = null;\r
-\r
-      // ----- Reset the file list\r
-      unset($v_header_list);\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Swap back the file descriptor\r
-    $v_swap = $this->zip_fd;\r
-    $this->zip_fd = $v_zip_temp_fd;\r
-    $v_zip_temp_fd = $v_swap;\r
-\r
-    // ----- Close\r
-    $this->privCloseFd();\r
-    $p_archive_to_add->privCloseFd();\r
-\r
-    // ----- Close the temporary file\r
-    @fclose($v_zip_temp_fd);\r
-\r
-    // ----- Delete the zip file\r
-    // TBC : I should test the result ...\r
-    @unlink($this->zipname);\r
-\r
-    // ----- Rename the temporary file\r
-    // TBC : I should test the result ...\r
-    //@rename($v_zip_temp_name, $this->zipname);\r
-    PclZipUtilRename($v_zip_temp_name, $this->zipname);\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privDuplicate()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function privDuplicate($p_archive_filename)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");\r
-    $v_result=1;\r
-\r
-    // ----- Look if the $p_archive_filename exists\r
-    if (!is_file($p_archive_filename))\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");\r
-\r
-      // ----- Nothing to duplicate, so duplicate is a success.\r
-      $v_result = 1;\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Open the zip file\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-    if (($v_result=$this->privOpenFd('wb')) != 1)\r
-    {\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-      return $v_result;\r
-    }\r
-\r
-    // ----- Open the temporary file in write mode\r
-    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
-    if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)\r
-    {\r
-      $this->privCloseFd();\r
-\r
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');\r
-\r
-      // ----- Return\r
-      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
-      return PclZip::errorCode();\r
-    }\r
-\r
-    // ----- Copy the files from the archive to the temporary file\r
-    // TBC : Here I should better append the file and go back to erase the central dir\r
-    $v_size = filesize($p_archive_filename);\r
-    while ($v_size != 0)\r
-    {\r
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");\r
-      $v_buffer = fread($v_zip_temp_fd, $v_read_size);\r
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);\r
-      $v_size -= $v_read_size;\r
-    }\r
-\r
-    // ----- Close\r
-    $this->privCloseFd();\r
-\r
-    // ----- Close the temporary file\r
-    @fclose($v_zip_temp_fd);\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privErrorLog()\r
-  // Description :\r
-  // Parameters :\r
-  // --------------------------------------------------------------------------------\r
-  function privErrorLog($p_error_code=0, $p_error_string='')\r
-  {\r
-    if (PCLZIP_ERROR_EXTERNAL == 1) {\r
-      PclError($p_error_code, $p_error_string);\r
-    }\r
-    else {\r
-      $this->error_code = $p_error_code;\r
-      $this->error_string = $p_error_string;\r
-    }\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : privErrorReset()\r
-  // Description :\r
-  // Parameters :\r
-  // --------------------------------------------------------------------------------\r
-  function privErrorReset()\r
-  {\r
-    if (PCLZIP_ERROR_EXTERNAL == 1) {\r
-      PclErrorReset();\r
-    }\r
-    else {\r
-      $this->error_code = 1;\r
-      $this->error_string = '';\r
-    }\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  }\r
-  // End of class\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : PclZipUtilPathReduction()\r
-  // Description :\r
-  // Parameters :\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function PclZipUtilPathReduction($p_dir)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'");\r
-    $v_result = "";\r
-\r
-    // ----- Look for not empty path\r
-    if ($p_dir != "")\r
-    {\r
-      // ----- Explode path by directory names\r
-      $v_list = explode("/", $p_dir);\r
-\r
-      // ----- Study directories from last to first\r
-      for ($i=sizeof($v_list)-1; $i>=0; $i--)\r
-      {\r
-        // ----- Look for current path\r
-        if ($v_list[$i] == ".")\r
-        {\r
-          // ----- Ignore this directory\r
-          // Should be the first $i=0, but no check is done\r
-        }\r
-        else if ($v_list[$i] == "..")\r
-        {\r
-          // ----- Ignore it and ignore the $i-1\r
-          $i--;\r
-        }\r
-        else if (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0))\r
-        {\r
-          // ----- Ignore only the double '//' in path,\r
-          // but not the first and last '/'\r
-        }\r
-        else\r
-        {\r
-          $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");\r
-        }\r
-      }\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : PclZipUtilPathInclusion()\r
-  // Description :\r
-  //   This function indicates if the path $p_path is under the $p_dir tree. Or,\r
-  //   said in an other way, if the file or sub-dir $p_path is inside the dir\r
-  //   $p_dir.\r
-  //   The function indicates also if the path is exactly the same as the dir.\r
-  //   This function supports path with duplicated '/' like '//', but does not\r
-  //   support '.' or '..' statements.\r
-  // Parameters :\r
-  // Return Values :\r
-  //   0 if $p_path is not inside directory $p_dir\r
-  //   1 if $p_path is inside directory $p_dir\r
-  //   2 if $p_path is exactly the same as $p_dir\r
-  // --------------------------------------------------------------------------------\r
-  function PclZipUtilPathInclusion($p_dir, $p_path)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");\r
-    $v_result = 1;\r
-\r
-    // ----- Explode dir and path by directory separator\r
-    $v_list_dir = explode("/", $p_dir);\r
-    $v_list_dir_size = sizeof($v_list_dir);\r
-    $v_list_path = explode("/", $p_path);\r
-    $v_list_path_size = sizeof($v_list_path);\r
-\r
-    // ----- Study directories paths\r
-    $i = 0;\r
-    $j = 0;\r
-    while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");\r
-\r
-      // ----- Look for empty dir (path reduction)\r
-      if ($v_list_dir[$i] == '') {\r
-        $i++;\r
-        continue;\r
-      }\r
-      if ($v_list_path[$j] == '') {\r
-        $j++;\r
-        continue;\r
-      }\r
-\r
-      // ----- Compare the items\r
-      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");\r
-        $v_result = 0;\r
-      }\r
-\r
-      // ----- Next items\r
-      $i++;\r
-      $j++;\r
-    }\r
-\r
-    // ----- Look if everything seems to be the same\r
-    if ($v_result) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");\r
-      // ----- Skip all the empty items\r
-      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;\r
-      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'");\r
-\r
-      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {\r
-        // ----- There are exactly the same\r
-        $v_result = 2;\r
-      }\r
-      else if ($i < $v_list_dir_size) {\r
-        // ----- The path is shorter than the dir\r
-        $v_result = 0;\r
-      }\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : PclZipUtilCopyBlock()\r
-  // Description :\r
-  // Parameters :\r
-  //   $p_mode : read/write compression mode\r
-  //             0 : src & dest normal\r
-  //             1 : src gzip, dest normal\r
-  //             2 : src normal, dest gzip\r
-  //             3 : src & dest gzip\r
-  // Return Values :\r
-  // --------------------------------------------------------------------------------\r
-  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");\r
-    $v_result = 1;\r
-\r
-    if ($p_mode==0)\r
-    {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));\r
-      while ($p_size != 0)\r
-      {\r
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-        $v_buffer = @fread($p_src, $v_read_size);\r
-        @fwrite($p_dest, $v_buffer, $v_read_size);\r
-        $p_size -= $v_read_size;\r
-      }\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));\r
-    }\r
-    else if ($p_mode==1)\r
-    {\r
-      while ($p_size != 0)\r
-      {\r
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-        $v_buffer = @gzread($p_src, $v_read_size);\r
-        @fwrite($p_dest, $v_buffer, $v_read_size);\r
-        $p_size -= $v_read_size;\r
-      }\r
-    }\r
-    else if ($p_mode==2)\r
-    {\r
-      while ($p_size != 0)\r
-      {\r
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-        $v_buffer = @fread($p_src, $v_read_size);\r
-        @gzwrite($p_dest, $v_buffer, $v_read_size);\r
-        $p_size -= $v_read_size;\r
-      }\r
-    }\r
-    else if ($p_mode==3)\r
-    {\r
-      while ($p_size != 0)\r
-      {\r
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
-        $v_buffer = @gzread($p_src, $v_read_size);\r
-        @gzwrite($p_dest, $v_buffer, $v_read_size);\r
-        $p_size -= $v_read_size;\r
-      }\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : PclZipUtilRename()\r
-  // Description :\r
-  //   This function tries to do a simple rename() function. If it fails, it\r
-  //   tries to copy the $p_src file in a new $p_dest file and then unlink the\r
-  //   first one.\r
-  // Parameters :\r
-  //   $p_src : Old filename\r
-  //   $p_dest : New filename\r
-  // Return Values :\r
-  //   1 on success, 0 on failure.\r
-  // --------------------------------------------------------------------------------\r
-  function PclZipUtilRename($p_src, $p_dest)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");\r
-    $v_result = 1;\r
-\r
-    // ----- Try to rename the files\r
-    if (!@rename($p_src, $p_dest)) {\r
-      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");\r
-\r
-      // ----- Try to copy & unlink the src\r
-      if (!@copy($p_src, $p_dest)) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");\r
-        $v_result = 0;\r
-      }\r
-      else if (!@unlink($p_src)) {\r
-        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");\r
-        $v_result = 0;\r
-      }\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : PclZipUtilOptionText()\r
-  // Description :\r
-  //   Translate option value in text. Mainly for debug purpose.\r
-  // Parameters :\r
-  //   $p_option : the option value.\r
-  // Return Values :\r
-  //   The option text value.\r
-  // --------------------------------------------------------------------------------\r
-  function PclZipUtilOptionText($p_option)\r
-  {\r
-    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");\r
-\r
-    switch ($p_option) {\r
-      case PCLZIP_OPT_PATH :\r
-        $v_result = 'PCLZIP_OPT_PATH';\r
-      break;\r
-      case PCLZIP_OPT_ADD_PATH :\r
-        $v_result = 'PCLZIP_OPT_ADD_PATH';\r
-      break;\r
-      case PCLZIP_OPT_REMOVE_PATH :\r
-        $v_result = 'PCLZIP_OPT_REMOVE_PATH';\r
-      break;\r
-      case PCLZIP_OPT_REMOVE_ALL_PATH :\r
-        $v_result = 'PCLZIP_OPT_REMOVE_ALL_PATH';\r
-      break;\r
-      case PCLZIP_OPT_EXTRACT_AS_STRING :\r
-        $v_result = 'PCLZIP_OPT_EXTRACT_AS_STRING';\r
-      break;\r
-      case PCLZIP_OPT_SET_CHMOD :\r
-        $v_result = 'PCLZIP_OPT_SET_CHMOD';\r
-      break;\r
-      case PCLZIP_OPT_BY_NAME :\r
-        $v_result = 'PCLZIP_OPT_BY_NAME';\r
-      break;\r
-      case PCLZIP_OPT_BY_INDEX :\r
-        $v_result = 'PCLZIP_OPT_BY_INDEX';\r
-      break;\r
-      case PCLZIP_OPT_BY_EREG :\r
-        $v_result = 'PCLZIP_OPT_BY_EREG';\r
-      break;\r
-      case PCLZIP_OPT_BY_PREG :\r
-        $v_result = 'PCLZIP_OPT_BY_PREG';\r
-      break;\r
-\r
-\r
-      case PCLZIP_CB_PRE_EXTRACT :\r
-        $v_result = 'PCLZIP_CB_PRE_EXTRACT';\r
-      break;\r
-      case PCLZIP_CB_POST_EXTRACT :\r
-        $v_result = 'PCLZIP_CB_POST_EXTRACT';\r
-      break;\r
-      case PCLZIP_CB_PRE_ADD :\r
-        $v_result = 'PCLZIP_CB_PRE_ADD';\r
-      break;\r
-      case PCLZIP_CB_POST_ADD :\r
-        $v_result = 'PCLZIP_CB_POST_ADD';\r
-      break;\r
-\r
-      default :\r
-        $v_result = 'Unknown';\r
-    }\r
-\r
-    // ----- Return\r
-    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
-    return $v_result;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-  // --------------------------------------------------------------------------------\r
-  // Function : PclZipUtilTranslateWinPath()\r
-  // Description :\r
-  //   Translate windows path by replacing '\' by '/' and optionally removing\r
-  //   drive letter.\r
-  // Parameters :\r
-  //   $p_path : path to translate.\r
-  //   $p_remove_disk_letter : true | false\r
-  // Return Values :\r
-  //   The path translated.\r
-  // --------------------------------------------------------------------------------\r
-  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)\r
-  {\r
-    if (stristr(php_uname(), 'windows')) {\r
-      // ----- Look for potential disk letter\r
-      if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {\r
-          $p_path = substr($p_path, $v_position+1);\r
-      }\r
-      // ----- Change potential windows directory separator\r
-      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {\r
-          $p_path = strtr($p_path, '\\', '/');\r
-      }\r
-    }\r
-    return $p_path;\r
-  }\r
-  // --------------------------------------------------------------------------------\r
-\r
-?>\r
+<?php
+
+/**
+ * PhpConcept Library - Zip Module 2.0-rc2
+ *
+ * License GNU/LGPL - Vincent Blavet - July 2003<br>
+ * {@link http://www.phpconcept.net}<br>
+ * --------------------------------------------------------------------------------
+ *
+ * Presentation :<br>
+ *   PclZip is a PHP library that manage ZIP archives.<br>
+ *   So far tests show that archives generated by PclZip are readable by
+ *   WinZip application and other tools.
+ *
+ * Description :<br>
+ *   See readme.txt and {@link http://www.phpconcept.net}<br>
+ *
+ * <b>Warning :</b><br>
+ *   This library and the associated files are non commercial, non professional
+ *   work.<br>
+ *   It should not have unexpected results. However if any damage is caused by
+ *   this software the author can not be responsible.
+ *   The use of this software is at the risk of the user.
+ *
+ * @author Vincent Blavet
+ * @version  2.0-rc2 $Id$
+ * @license GNU/LGPL
+ * @package PCLZIP
+ */
+
+/// GLOBAL CONSTANTS /////////////////////////////////////////////////////////
+
+    /**
+     * Read block size
+     */
+  define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
+  
+  /** 
+   * File list separator.
+   *
+   * In version 1.x of PclZip, the separator for file list is a space
+   * (which is not a very smart choice, specifically for windows paths !).
+   * A better separator should be a comma (,). This constant gives you the
+   * abilty to change that.<br>
+   * However notice that changing this value may have impact on existing
+   * scripts which use space separated filenames.
+   * Recommended values for compatibility with older versions :
+   * <code>
+   * define( 'PCLZIP_SEPARATOR', ' ' );
+   * </code>
+   * Recommended values for smart separation of filenames.
+   */
+  define( 'PCLZIP_SEPARATOR', ',' );
+
+  /** 
+   * Error configuration.
+   *
+   * Value of 0 = PclZip Class integrated error handling
+   * Value of 1 = PclError external library error handling. By enabling this
+   *     you must ensure that you have included PclError library.
+   * [2,...] : reserved for future use
+   */
+  define( 'PCLZIP_ERROR_EXTERNAL', 0 );
+
+  /**
+   *  Optional static temporary directory.
+   *
+   *       By default temporary files are generated in the script current
+   *       path.<br>
+   *       If defined :
+   *       - MUST BE terminated by a '/'.
+   *       - MUST be a valid, already created directory
+   *       Samples :
+   * <code>
+   * define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
+   * define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
+   * </code>
+   */
+  define( 'PCLZIP_TEMPORARY_DIR', '' );
+
+// --------------------------------------------------------------------------------
+// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
+// --------------------------------------------------------------------------------
+
+  // ----- Global variables
+  /**
+   * @global string $g_pclzip_version
+   */
+  $g_pclzip_version = '2.0-rc2';
+
+  /**
+   * Error code: No error
+   */
+  define( 'PCLZIP_ERR_NO_ERROR', 0 );
+  /**
+   * Error code: Unable to open file in binary write mode
+   */
+  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
+  /**
+   * Error code: Unable to open file in binary read mode
+   */
+  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
+  /**
+   * Error code: Invalid parameters
+   */
+  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
+  /**
+   * Error code: File does not exist
+   */
+  define( 'PCLZIP_ERR_MISSING_FILE', -4 );
+  /**
+   * Error code: Filename is too long (max. 255)
+   */
+  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
+  /**
+   * Error code: Not a valid zip file
+   */
+  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
+  /**
+   * Error code: Invalid extracted file size
+   */
+  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
+  /**
+   * Error code: Unable to create directory
+   */
+  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
+  /**
+   * Error code:  Invalid archive extension
+   */
+  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
+  /**
+   * Error code: Invalid archive format
+   */
+  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
+  /**
+   * Error code: Unable to delete file (unlink)
+   */
+  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
+  /**
+   * Error code: Unable to rename file (rename)
+   */
+  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
+  /**
+   * Error code: Invalid header checksum
+   */
+  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
+  /**
+   * Error code: Invalid archive size
+   */
+  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
+  /**
+   * Error code: Missing option
+   */
+  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
+  /**
+   * Error code: Invalid option
+   */
+  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
+
+  // ----- Options values
+  /**
+   * Option: path
+   */
+  define( 'PCLZIP_OPT_PATH', 77001 );
+  /**
+   * Option: Add path
+   */
+  define( 'PCLZIP_OPT_ADD_PATH', 77002 );
+  /**
+   * Option: Remove path
+   */
+  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
+  /**
+   * Option: Remove all paths
+   */
+  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
+  /**
+   * Option: Set chmod
+   */
+  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
+  /**
+   * Option: Extract as string
+   */
+  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
+  /**
+   * Option: No compression
+   */
+  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
+  /**
+   * Option: By name
+   */
+  define( 'PCLZIP_OPT_BY_NAME', 77008 );
+  /**
+   * Option: By index
+   */
+  define( 'PCLZIP_OPT_BY_INDEX', 77009 );
+  /**
+   * Option: By ereg
+   */
+  define( 'PCLZIP_OPT_BY_EREG', 77010 );
+  /**
+   * Option: By preg
+   */
+  define( 'PCLZIP_OPT_BY_PREG', 77011 );
+
+  // ----- Call backs values
+  /**
+   * Call back: Pre-extract
+   */
+  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
+  /**
+   * Call back: Post-extract
+   */
+  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
+  /**
+   * Call back: Pre-add
+   */
+  define( 'PCLZIP_CB_PRE_ADD', 78003 );
+  /**
+   * Call back: Post-add
+   */
+  define( 'PCLZIP_CB_POST_ADD', 78004 );
+  /* For future use
+  define( 'PCLZIP_CB_PRE_LIST', 78005 );
+  define( 'PCLZIP_CB_POST_LIST', 78006 );
+  define( 'PCLZIP_CB_PRE_DELETE', 78007 );
+  define( 'PCLZIP_CB_POST_DELETE', 78008 );
+  */
+
+/**
+ *   PclZip is the class that represent a Zip archive.
+ *
+ *   The public methods allow for the manipulation of the archive.<br>
+ *
+ * Public Methods :
+ *  - {@link PclZip()} : Object creator
+ *  - {@link create()} : Creates the Zip archive
+ *  - {@link listContent()} : List the content of the Zip archive
+ *  - {@link extract()} : Extract the content of the archive
+ *  - {@link properties()} : List the properties of the archive
+ */
+  class PclZip
+  {
+    /**
+     * Filename of the zip file
+     * @var string $zipname
+     */
+    var $zipname = '';
+
+    /**
+     * File descriptor of the zip file
+     * @var int $zip_fd
+     */
+     var $zip_fd = 0;
+
+    /**
+     * Internal error handling
+     * @var int $error_code
+     */
+    var $error_code = 1;
+
+    /**
+     * Internal error handling
+     * @var string $error_string
+     */
+    var $error_string = '';
+
+
+  /**
+  * Object creator
+  *
+  * Description :
+  *   Creates a PclZip object and sets the name of the associated Zip archive
+  *   filename.<br>
+  *   Note that no real action is taken, if the archive does not exist it is not
+  *   created. Use {@link create()} for that.
+  * @param string $p_zipname The name of the associated Zip archive
+  *   filename
+  */
+  function PclZip($p_zipname)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");
+
+    // ----- Tests the zlib
+    if (!function_exists('gzopen'))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");
+      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
+    }
+
+    // ----- Set the attributes
+    $this->zipname = $p_zipname;
+    $this->zip_fd = 0;
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
+    return;
+  }
+  // --------------------------------------------------------------------------------
+
+
+  /**
+  * Creates the Zip archive.
+  *
+  * Description :
+  *   This method supports two different synopsis. The first one is historical.
+  *   This method creates a Zip Archive. The Zip file is created in the
+  *   filesystem. The files and directories indicated in $p_filelist
+  *   are added in the archive. See the parameters description for the
+  *   supported format of $p_filelist.
+  *   When a directory is in the list, the directory and its content is added
+  *   in the archive.<br>
+  *   In this synopsis, the function takes an optional variable list of
+  *   options.
+  *
+  * Example usage:
+  * <code>
+  *  create($p_filelist, $p_add_dir="", $p_remove_dir="")
+  *  create($p_filelist, $p_option, $p_option_value, ...)
+  * </code>
+  * Supported options :
+  *   - PCLZIP_OPT_ADD_PATH 
+  *   - PCLZIP_OPT_REMOVE_PATH 
+  *   - PCLZIP_OPT_REMOVE_ALL_PATH 
+  *   - PCLZIP_CB_PRE_ADD 
+  *   - PCLZIP_CB_POST_ADD 
+  *
+  * @param array  $p_filelist  An array containing file or directory names, or
+  *                 a string containing one filename or one directory name, or
+  *                 a string containing a list of filenames and/or directory
+  *                 names separated by spaces.
+  * @param string  $p_add_dir A path to add before the real path of the archived file,
+  *                in order to have it memorized in the archive.
+  * @param string  $p_remove_dir A path to remove from the real path of the file to archive,
+  *                   in order to have a shorter path memorized in the archive.
+  *                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
+  *                   is removed first, before $p_add_dir is added.
+  * @return int|string  0 on failure or the list of the added files, 
+  *                           with a status of the add action.
+  *                    (see {@link PclZip::listContent()} for returned list entry format)
+  * @access public
+  */
+//  function create($p_filelist, $p_add_dir="", $p_remove_dir="")
+  function create($p_filelist /*, options */)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Set default values
+    $v_options = array();
+    $v_add_path = '';
+    $v_remove_path = '';
+    $v_remove_all_path = false;
+    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
+
+    // ----- Look for arguments
+    if ($v_size > 1) {
+      // ----- Get the arguments
+      $v_arg_list = &func_get_args();
+
+      // ----- Remove form the options list the first argument
+      array_shift($v_arg_list);
+      $v_size--;
+
+      // ----- Look for first arg
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
+
+        // ----- Parse the options
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',
+                                                   PCLZIP_CB_PRE_ADD => 'optional',
+                                                   PCLZIP_CB_POST_ADD => 'optional',
+                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional' ));
+        if ($v_result != 1) {
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+          return 0;
+        }
+
+        // ----- Set the arguments
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
+          $v_add_path = $v_options[PCLZIP_OPT_ADD_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+        }
+      }
+
+      // ----- Look for 2 args
+      // Here we need to support the first historic synopsis of the
+      // method.
+      else {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
+
+        // ----- Get the first argument
+        $v_add_path = $v_arg_list[0];
+
+        // ----- Look for the optional second argument
+        if ($v_size == 2) {
+          $v_remove_path = $v_arg_list[1];
+        }
+        else if ($v_size > 2) {
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 'Invalid number / type of arguments');
+
+          // ----- Return
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+          return 0;
+        }
+      }
+    }
+
+    // ----- Trace
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");
+
+    // ----- Look if the $p_filelist is really an array
+    $p_result_list = array();
+    if (is_array($p_filelist))
+    {
+      // ----- Call the create fct
+      $v_result = $this->privCreate($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
+    }
+
+    // ----- Look if the $p_filelist is a string
+    else if (is_string($p_filelist))
+    {
+      // ----- Create a list with the elements from the string
+      $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);
+
+      // ----- Call the create fct
+      $v_result = $this->privCreate($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
+    }
+
+    // ----- Invalid variable
+    else
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 'Invalid variable type p_filelist');
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
+    }
+
+    if ($v_result != 1)
+    {
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+      return 0;
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
+    return $p_result_list;
+  }
+  // --------------------------------------------------------------------------------
+
+
+  /**
+  * This method adds the list of files in an existing archive.
+  *
+  * Description :<br>
+  *   This method supports two synopsis. The first one is historical.
+  *   This method adds the list of files in an existing archive.
+  *   If a file with the same name already exists, it is added at the end of the
+  *   archive, the first one is still present.
+  *   If the archive does not exist, it is created.<br>
+  *
+  * Example usage:
+  * <code>
+  *  add($p_filelist, $p_add_dir="", $p_remove_dir="")
+  *  add($p_filelist, $p_option, $p_option_value, ...)
+  * </code>
+  * Supported options :
+  *   - PCLZIP_OPT_ADD_PATH 
+  *   - PCLZIP_OPT_REMOVE_PATH 
+  *   - PCLZIP_OPT_REMOVE_ALL_PATH 
+  *   - PCLZIP_CB_PRE_ADD 
+  *   - PCLZIP_CB_POST_ADD 
+  *
+  * @param array $p_filelist An array containing file or directory names, or
+  *                 a string containing one filename or one directory name, or
+  *                 a string containing a list of filenames and/or directory
+  *                 names separated by spaces.
+  * @param string $p_add_dir A path to add before the real path of the archived file,
+  *                in order to have it memorized in the archive.
+  * @param string $p_remove_dir A path to remove from the real path of the file to archive,
+  *                   in order to have a shorter path memorized in the archive.
+  *                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
+  *                   is removed first, before $p_add_dir is added.
+  * @return int|string  0 on failure or the list of the added files, 
+  *                           with a status of the add action.
+  *                    (see {@link PclZip::listContent()} for returned list entry format)
+  * @access public
+  */
+//  function add($p_filelist, $p_add_dir="", $p_remove_dir="")
+  function add($p_filelist /* options */)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Set default values
+    $v_options = array();
+    $v_add_path = '';
+    $v_remove_path = '';
+    $v_remove_all_path = false;
+    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
+
+    // ----- Look for arguments
+    if ($v_size > 1) {
+      // ----- Get the arguments
+      $v_arg_list = &func_get_args();
+
+      // ----- Remove form the options list the first argument
+      array_shift($v_arg_list);
+      $v_size--;
+
+      // ----- Look for first arg
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
+
+        // ----- Parse the options
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',
+                                                   PCLZIP_CB_PRE_ADD => 'optional',
+                                                   PCLZIP_CB_POST_ADD => 'optional',
+                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional' ));
+        if ($v_result != 1) {
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+          return 0;
+        }
+
+        // ----- Set the arguments
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
+          $v_add_path = $v_options[PCLZIP_OPT_ADD_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+        }
+      }
+
+      // ----- Look for 2 args
+      // Here we need to support the first historic synopsis of the
+      // method.
+      else {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
+
+        // ----- Get the first argument
+        $v_add_path = $v_arg_list[0];
+
+        // ----- Look for the optional second argument
+        if ($v_size == 2) {
+          $v_remove_path = $v_arg_list[1];
+        }
+        else if ($v_size > 2) {
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 'Invalid number / type of arguments');
+
+          // ----- Return
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+          return 0;
+        }
+      }
+    }
+
+    // ----- Trace
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");
+
+    // ----- Look if the $p_filelist is really an array
+    $p_result_list = array();
+    if (is_array($p_filelist))
+    {
+      // ----- Call the create fct
+      $v_result = $this->privAdd($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
+    }
+
+    // ----- Look if the $p_filelist is a string
+    else if (is_string($p_filelist))
+    {
+      // ----- Create a list with the elements from the string
+      $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);
+
+      // ----- Call the create fct
+      $v_result = $this->privAdd($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
+    }
+
+    // ----- Invalid variable
+    else
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 'Invalid variable type p_filelist');
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
+    }
+
+    if ($v_result != 1)
+    {
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+      return 0;
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
+    return $p_result_list;
+  }
+  // --------------------------------------------------------------------------------
+
+  /**
+  * List the content of the Zip archive.
+  *
+  *   This public method, gives the list of the files and directories, with their
+  *   properties.
+  *   The properties of each of the  entries in the list returned are (used also in other functions) :
+  *     - filename : Name of the file. For a create or add action it is the filename
+  *                given by the user. For an extract function it is the filename
+  *                of the extracted file.
+  *     - stored_filename : Name of the file / directory stored in the archive.
+  *     - size : Size of the stored file.
+  *     - compressed_size : Size of the file's data compressed in the archive
+  *                       (without the headers overhead)
+  *     - mtime : Last known modification date of the file (UNIX timestamp)
+  *     - comment : Comment associated with the file
+  *     - folder : true | false
+  *     - index : index of the file in the archive
+  *     - status : status of the action (depending of the action). 
+  
+  *     Valid values for status property are :
+  *                - ok : OK !
+  *                - filtered : the file / dir is not extracted (filtered by user)
+  *                - already_a_directory : the file can not be extracted because a
+  *                                      directory with the same name already exists
+  *                - write_protected : the file can not be extracted because a file
+  *                                  with the same name already exists and is
+  *                                  write protected
+  *                - newer_exist : the file was not extracted because a newer file exists
+  *                - path_creation_fail : the file is not extracted because the folder
+  *                                     does not exists and can not be created
+  *                - write_error : the file was not extracted because there was a
+  *                              error while writing the file
+  *                - read_error : the file was not extracted because there was a error
+  *                             while reading the file
+  *                - invalid_header : the file was not extracted because of an archive
+  *                                 format error (bad file header)
+  *
+  *   Note that each time a method can continue operating when there
+  *   is an action error on a file, the error is only logged in the file status.
+  * @return int|array Returns 0 on an unrecoverable failure,
+  *                   or the list of the files in the archive.
+  * @access public
+  */
+  function listContent()
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+      return(0);
+    }
+
+    // ----- Call the extracting fct
+    $p_list = array();
+    if (($v_result = $this->privList($p_list)) != 1)
+    {
+      unset($p_list);
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
+      return(0);
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
+    return $p_list;
+  }
+  // --------------------------------------------------------------------------------
+
+ /** 
+  * Extract the content of the archive
+  * 
+  * Description :<br>
+  *   This method supports two synopsis. The first one is historical.
+  *   This method extract all the files / directories from the archive to the
+  *   folder indicated in $p_path.<br>
+  *   If you want to ignore the 'root' part of path of the memorized files
+  *   you can indicate this in the optional $p_remove_path parameter.
+  *   By default, if a newer file with the same name already exists, the
+  *   file is not extracted.
+  *
+  * Example usage:
+  * <code>
+  *   extract($p_path="./", $p_remove_path="")
+  *   extract([$p_option, $p_option_value, ...])
+  * </code>
+  *
+  *   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH options
+  *   are used, the path indicated in PCLZIP_OPT_ADD_PATH is appended
+  *   to the end of the path value of PCLZIP_OPT_PATH.<br>
+  * Supported options :
+  *   - PCLZIP_OPT_ADD_PATH 
+  *   - PCLZIP_OPT_REMOVE_PATH 
+  *   - PCLZIP_OPT_REMOVE_ALL_PATH 
+  *   - PCLZIP_CB_PRE_ADD 
+  *   - PCLZIP_CB_POST_ADD 
+  *
+  * @param string $p_path Path where the files and directories are to be extracted
+  * @param string $p_remove_path First part ('root' part) of the memorized path
+  *                    (if any similar) to remove while extracting.
+  * @return int|array  Returns 0 or a negative value on failure,
+  *                    or the list of the extracted files, with a status of the action.
+  *                    (see {@link PclZip::listContent()} for returned list entry format)
+  * @access public
+  */
+  //function extract($p_path="./", $p_remove_path="")
+  function extract(/* options */)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+      return(0);
+    }
+
+    // ----- Set default values
+    $v_options = array();
+    $v_path = './';
+    $v_remove_path = '';
+    $v_remove_all_path = false;
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
+
+    // ----- Default values for option
+    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
+
+    // ----- Look for arguments
+    if ($v_size > 0) {
+      // ----- Get the arguments
+      $v_arg_list = &func_get_args();
+
+      // ----- Look for first arg
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
+
+        // ----- Parse the options
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                            array (PCLZIP_OPT_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',
+                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
+                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
+                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
+                                                   PCLZIP_OPT_BY_NAME => 'optional',
+                                                   PCLZIP_OPT_BY_EREG => 'optional',
+                                                   PCLZIP_OPT_BY_PREG => 'optional',
+                                                   PCLZIP_OPT_BY_INDEX => 'optional',
+                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional' ));
+        if ($v_result != 1) {
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+          return 0;
+        }
+
+        // ----- Set the arguments
+        if (isset($v_options[PCLZIP_OPT_PATH])) {
+          $v_path = $v_options[PCLZIP_OPT_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
+          // ----- Check for '/' in last path char
+          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
+            $v_path .= '/';
+          }
+          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
+        }
+      }
+
+      // ----- Look for 2 args
+      // Here we need to support the first historic synopsis of the
+      // method.
+      else {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
+
+        // ----- Get the first argument
+        $v_path = $v_arg_list[0];
+
+        // ----- Look for the optional second argument
+        if ($v_size == 2) {
+          $v_remove_path = $v_arg_list[1];
+        }
+        else if ($v_size > 2) {
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 'Invalid number / type of arguments');
+
+          // ----- Return
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
+          return 0;
+        }
+      }
+    }
+
+    // ----- Trace
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
+
+    // ----- Call the extracting fct
+    $p_list = array();
+    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1)
+    {
+      unset($p_list);
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
+      return(0);
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
+    return $p_list;
+  }
+  // --------------------------------------------------------------------------------
+
+
+  // --------------------------------------------------------------------------------
+  // Function :
+  //   extractByIndex($p_index, $p_path="./", $p_remove_path="")
+  //   extractByIndex($p_index, [$p_option, $p_option_value, ...])
+  // Description :
+  //   This method supports two synopsis. The first one is historical.
+  //   This method is doing a partial extract of the archive.
+  //   The extracted files or folders are identified by their index in the
+  //   archive (from 0 to n).
+  //   Note that if the index identify a folder, only the folder entry is
+  //   extracted, not all the files included in the archive.
+  // Parameters :
+  //   $p_index : A single index (integer) or a string of indexes of files to
+  //              extract. The form of the string is "0,4-6,8-12" with only numbers
+  //              and '-' for range or ',' to separate ranges. No spaces or ';'
+  //              are allowed.
+  //   $p_path : Path where the files and directories are to be extracted
+  //   $p_remove_path : First part ('root' part) of the memorized path
+  //                    (if any similar) to remove while extracting.
+  // Options :
+  //   PCLZIP_OPT_PATH :
+  //   PCLZIP_OPT_ADD_PATH :
+  //   PCLZIP_OPT_REMOVE_PATH :
+  //   PCLZIP_OPT_REMOVE_ALL_PATH :
+  //   PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
+  //     not as files.
+  //     The resulting content is in a new field 'content' in the file
+  //     structure.
+  //     This option must be used alone (any other options are ignored).
+  //   PCLZIP_CB_PRE_EXTRACT :
+  //   PCLZIP_CB_POST_EXTRACT :
+  // Return Values :
+  //   0 on failure,
+  //   The list of the extracted files, with a status of the action.
+  //   (see PclZip::listContent() for list entry format)
+  // --------------------------------------------------------------------------------
+  function extractByIndex($p_index /* $options */)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+      return(0);
+    }
+
+    // ----- Set default values
+    $v_options = array();
+    $v_path = './';
+    $v_remove_path = '';
+    $v_remove_all_path = false;
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
+
+    // ----- Default values for option
+    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
+
+    // ----- Look for arguments
+    if ($v_size > 1) {
+      // ----- Get the arguments
+      $v_arg_list = &func_get_args();
+
+      // ----- Remove form the options list the first argument
+      array_shift($v_arg_list);
+      $v_size--;
+
+      // ----- Look for first arg
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
+
+        // ----- Parse the options
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                            array (PCLZIP_OPT_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',
+                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
+                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
+                                                   PCLZIP_OPT_SET_CHMOD => 'optional' ));
+        if ($v_result != 1) {
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+          return 0;
+        }
+
+        // ----- Set the arguments
+        if (isset($v_options[PCLZIP_OPT_PATH])) {
+          $v_path = $v_options[PCLZIP_OPT_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
+          // ----- Check for '/' in last path char
+          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
+            $v_path .= '/';
+          }
+          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
+        }
+        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
+          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");
+        }
+        else {
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");
+        }
+      }
+
+      // ----- Look for 2 args
+      // Here we need to support the first historic synopsis of the
+      // method.
+      else {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
+
+        // ----- Get the first argument
+        $v_path = $v_arg_list[0];
+
+        // ----- Look for the optional second argument
+        if ($v_size == 2) {
+          $v_remove_path = $v_arg_list[1];
+        }
+        else if ($v_size > 2) {
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 'Invalid number / type of arguments');
+
+          // ----- Return
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+          return 0;
+        }
+      }
+    }
+
+    // ----- Trace
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
+
+    // ----- Trick
+    // Here I want to reuse extractByRule(), so I need to parse the $p_index
+    // with privParseOptions()
+    $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
+    $v_options_trick = array();
+    $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
+                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));
+    if ($v_result != 1) {
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+        return 0;
+    }
+    $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
+
+    // ----- Call the extracting fct
+    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1) {
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
+        return(0);
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
+    return $p_list;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function :
+  //   delete([$p_option, $p_option_value, ...])
+  // Description :
+  // Parameters :
+  //   None
+  // Options :
+  //   PCLZIP_OPT_BY_INDEX :
+  // Return Values :
+  //   0 on failure,
+  //   The list of the files which are still present in the archive.
+  //   (see PclZip::listContent() for list entry format)
+  // --------------------------------------------------------------------------------
+  function delete(/* options */)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+      return(0);
+    }
+
+    // ----- Set default values
+    $v_options = array();
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
+
+    // ----- Look for no arguments
+    if ($v_size <= 0) {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 'Missing arguments');
+
+        // ----- Return
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
+        return 0;
+    }
+
+    // ----- Get the arguments
+    $v_arg_list = &func_get_args();
+
+    // ----- Parse the options
+    $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                        array (PCLZIP_OPT_BY_NAME => 'optional',
+                                               PCLZIP_OPT_BY_EREG => 'optional',
+                                               PCLZIP_OPT_BY_PREG => 'optional',
+                                               PCLZIP_OPT_BY_INDEX => 'optional' ));
+    if ($v_result != 1) {
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+        return 0;
+    }
+
+    // ----- Check that at least one rule is set
+    if (   (!isset($v_options[PCLZIP_OPT_BY_NAME]))
+        && (!isset($v_options[PCLZIP_OPT_BY_EREG]))
+        && (!isset($v_options[PCLZIP_OPT_BY_PREG]))
+        && (!isset($v_options[PCLZIP_OPT_BY_INDEX]))) {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, 'At least one filtering rule must be set');
+
+        // ----- Return
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
+        return 0;
+    }
+
+    // ----- Call the delete fct
+    $v_list = array();
+    if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1)
+    {
+      unset($v_list);
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
+      return(0);
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);
+    return $v_list;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : deleteByIndex()
+  // Description :
+  //   ***** Deprecated *****
+  //   delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
+  // --------------------------------------------------------------------------------
+  function deleteByIndex($p_index)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");
+    
+    $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
+    return $p_list;
+  }
+  // --------------------------------------------------------------------------------
+
+
+ /**
+  * List the properties of the archive
+  *
+  *   This method returns the properties of the archive.
+  *   The properties are :
+  *     - nb : Number of files in the archive
+  *     - comment : Comment associated with the archive file
+  *     - status : not_exist, ok
+  * @return int|array Returns 0 on failure,
+  *                     or an array with the archive properties.
+  * @access public
+  */
+  function properties()
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+      return(0);
+    }
+
+    // ----- Default properties
+    $v_prop = array();
+    $v_prop['comment'] = '';
+    $v_prop['nb'] = 0;
+    $v_prop['status'] = 'not_exist';
+
+    // ----- Look if file exists
+    if (@is_file($this->zipname))
+    {
+      // ----- 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)
+      {
+        // ----- 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(), 0);
+        return 0;
+      }
+
+      // ----- Read the central directory informations
+      $v_central_dir = array();
+      if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+        return 0;
+      }
+
+      // ----- Close the zip file
+      $this->privCloseFd();
+
+      // ----- Set the user attributes
+      $v_prop['comment'] = $v_central_dir['comment'];
+      $v_prop['nb'] = $v_central_dir['entries'];
+      $v_prop['status'] = 'ok';
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);
+    return $v_prop;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : duplicate()
+  // Description :
+  //   This method creates an archive by copying the content of an other one. If
+  //   the archive already exist, it is replaced by the new one without any warning.
+  // Parameters :
+  //   $p_archive : The filename of a valid archive, or
+  //                a valid PclZip object.
+  // Return Values :
+  //   1 on success.
+  //   0 or a negative value on error (error code).
+  // --------------------------------------------------------------------------------
+  function duplicate($p_archive)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");
+    $v_result = 1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Look if the $p_archive is a PclZip object
+    if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");
+
+      // ----- Duplicate the archive
+      $v_result = $this->privDuplicate($p_archive->zipname);
+    }
+
+    // ----- Look if the $p_archive is a string (so a filename)
+    else if (is_string($p_archive))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'");
+
+      // ----- Check that $p_archive is a valid zip file
+      // TBC : Should also check the archive format
+      if (!is_file($p_archive)) {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
+        $v_result = PCLZIP_ERR_MISSING_FILE;
+      }
+      else {
+        // ----- Duplicate the archive
+        $v_result = $this->privDuplicate($p_archive);
+      }
+    }
+
+    // ----- Invalid variable
+    else
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : merge()
+  // Description :
+  //   This method merge the $p_archive_to_add archive at the end of the current
+  //   one ($this).
+  //   If the archive ($this) does not exist, the merge becomes a duplicate.
+  //   If the $p_archive_to_add archive does not exist, the merge is a success.
+  // Parameters :
+  //   $p_archive_to_add : It can be directly the filename of a valid zip archive,
+  //                       or a PclZip object archive.
+  // Return Values :
+  //   1 on success,
+  //   0 or negative values on error (see below).
+  // --------------------------------------------------------------------------------
+  function merge($p_archive_to_add)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");
+    $v_result = 1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
+      return(0);
+    }
+
+    // ----- Look if the $p_archive_to_add is a PclZip object
+    if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");
+
+      // ----- Merge the archive
+      $v_result = $this->privMerge($p_archive_to_add);
+    }
+
+    // ----- Look if the $p_archive_to_add is a string (so a filename)
+    else if (is_string($p_archive_to_add))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");
+
+      // ----- Create a temporary archive
+      $v_object_archive = new PclZip($p_archive_to_add);
+
+      // ----- Merge the archive
+      $v_result = $this->privMerge($v_object_archive);
+    }
+
+    // ----- Invalid variable
+    else
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+
+
+  // --------------------------------------------------------------------------------
+  // Function : errorCode()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function errorCode()
+  {
+    if (PCLZIP_ERROR_EXTERNAL == 1) {
+      return(PclErrorCode());
+    }
+    else {
+      return($this->error_code);
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : errorName()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function errorName($p_with_code=false)
+  {
+    $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
+                      PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
+                      PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
+                      PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
+                      PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
+                      PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
+                      PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
+                      PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
+                      PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
+                      PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
+                      PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
+                      PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
+                      PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
+                      PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
+                      PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
+                      PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
+                      PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE' );
+
+    if (isset($v_name[$this->error_code])) {
+      $v_value = $v_name[$this->error_code];
+    }
+    else {
+      $v_value = 'NoName';
+    }
+
+    if ($p_with_code) {
+      return($v_value.' ('.$this->error_code.')');
+    }
+    else {
+      return($v_value);
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : errorInfo()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function errorInfo($p_full=false)
+  {
+    if (PCLZIP_ERROR_EXTERNAL == 1) {
+      return(PclErrorString());
+    }
+    else {
+      if ($p_full) {
+        return($this->errorName(true)." : ".$this->error_string);
+      }
+      else {
+        return($this->error_string." [code ".$this->error_code."]");
+      }
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------------
+// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
+// *****                                                        *****
+// *****       THESES FUNCTIONS MUST NOT BE USED DIRECTLY       *****
+// --------------------------------------------------------------------------------
+
+
+
+  // --------------------------------------------------------------------------------
+  // Function : privCheckFormat()
+  // Description :
+  //   This method check that the archive exists and is a valid zip archive.
+  //   Several level of check exists. (futur)
+  // Parameters :
+  //   $p_level : Level of check. Default 0.
+  //              0 : Check the first bytes (magic codes) (default value))
+  //              1 : 0 + Check the central directory (futur)
+  //              2 : 1 + Check each file header (futur)
+  // Return Values :
+  //   true on success,
+  //   false on error, the error code is set.
+  // --------------------------------------------------------------------------------
+  function privCheckFormat($p_level=0)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");
+    $v_result = true;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Look if the file exits
+    if (!is_file($this->zipname)) {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
+      return(false);
+    }
+
+    // ----- Check that the file is readeable
+    if (!is_readable($this->zipname)) {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
+      return(false);
+    }
+
+    // ----- Check the magic code
+    // TBC
+
+    // ----- Check the central header
+    // TBC
+
+    // ----- Check each file header
+    // TBC
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privParseOptions()
+  // Description :
+  //   This internal methods reads the variable list of arguments ($p_options_list,
+  //   $p_size) and generate an array with the options and values ($v_result_list).
+  //   $v_requested_options contains the options that can be present and those that
+  //   must be present.
+  //   $v_requested_options is an array, with the option value as key, and 'optional',
+  //   or 'mandatory' as value.
+  // Parameters :
+  //   See above.
+  // Return Values :
+  //   1 on success.
+  //   0 on failure.
+  // --------------------------------------------------------------------------------
+  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");
+    $v_result=1;
+
+    // ----- Read the options
+    $i=0;
+    while ($i<$p_size) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");
+
+      // ----- Check if the option is requested
+      if (!isset($v_requested_options[$p_options_list[$i]])) {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
+
+        // ----- Return
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+        return PclZip::errorCode();
+      }
+
+      // ----- Look for next option
+      switch ($p_options_list[$i]) {
+        // ----- Look for options that request a path value
+        case PCLZIP_OPT_PATH :
+        case PCLZIP_OPT_REMOVE_PATH :
+        case PCLZIP_OPT_ADD_PATH :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
+          $i++;
+        break;
+
+        // ----- Look for options that request an array of string for value
+        case PCLZIP_OPT_BY_NAME :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          if (is_string($p_options_list[$i+1])) {
+              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
+          }
+          else if (is_array($p_options_list[$i+1])) {
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
+          }
+          else {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+          ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
+          $i++;
+        break;
+
+        // ----- Look for options that request an EREG or PREG expression
+        case PCLZIP_OPT_BY_EREG :
+        case PCLZIP_OPT_BY_PREG :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          if (is_string($p_options_list[$i+1])) {
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
+          }
+          else {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
+          $i++;
+        break;
+
+        // ----- Look for options that request an array of index
+        case PCLZIP_OPT_BY_INDEX :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          $v_work_list = array();
+          if (is_string($p_options_list[$i+1])) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'");
+
+              // ----- Remove spaces
+              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
+
+              // ----- Parse items
+              $v_work_list = explode(",", $p_options_list[$i+1]);
+          }
+          else if (is_integer($p_options_list[$i+1])) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'");
+              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
+          }
+          else if (is_array($p_options_list[$i+1])) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");
+              $v_work_list = $p_options_list[$i+1];
+          }
+          else {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+          
+          // ----- Reduce the index list
+          // each index item in the list must be a couple with a start and
+          // an end value : [0,3], [5-5], [8-10], ...
+          // ----- Check the format of each item
+          $v_sort_flag=false;
+          $v_sort_value=0;
+          for ($j=0; $j<sizeof($v_work_list); $j++) {
+              // ----- Explode the item
+              $v_item_list = explode("-", $v_work_list[$j]);
+              $v_size_item_list = sizeof($v_item_list);
+              
+              // ----- TBC : Here we might check that each item is a
+              // real integer ...
+              
+              // ----- Look for single value
+              if ($v_size_item_list == 1) {
+                  // ----- Set the option value
+                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
+                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
+              }
+              elseif ($v_size_item_list == 2) {
+                  // ----- Set the option value
+                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
+                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
+              }
+              else {
+                  // ----- Error log
+                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+                  // ----- Return
+                  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+                  return PclZip::errorCode();
+              }
+
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extracted index item = [".$v_result_list[$p_options_list[$i]][$j]['start'].",".$v_result_list[$p_options_list[$i]][$j]['end']."]");
+
+              // ----- Look for list sort
+              if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");
+                  $v_sort_flag=true;
+
+                  // ----- TBC : An automatic sort should be writen ...
+                  // ----- Error log
+                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+                  // ----- Return
+                  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+                  return PclZip::errorCode();
+              }
+              $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
+          }
+          
+          // ----- Sort the items
+          if ($v_sort_flag) {
+              // TBC : To Be Completed
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ...");
+          }
+
+          // ----- Next option
+          $i++;
+        break;
+
+        // ----- Look for options that request no value
+        case PCLZIP_OPT_REMOVE_ALL_PATH :
+        case PCLZIP_OPT_EXTRACT_AS_STRING :
+        case PCLZIP_OPT_NO_COMPRESSION :
+          $v_result_list[$p_options_list[$i]] = true;
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
+        break;
+
+        // ----- Look for options that request an octal value
+        case PCLZIP_OPT_SET_CHMOD :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
+          $i++;
+        break;
+
+        // ----- Look for options that request a call-back
+        case PCLZIP_CB_PRE_EXTRACT :
+        case PCLZIP_CB_POST_EXTRACT :
+        case PCLZIP_CB_PRE_ADD :
+        case PCLZIP_CB_POST_ADD :
+        /* for futur use
+        case PCLZIP_CB_PRE_DELETE :
+        case PCLZIP_CB_POST_DELETE :
+        case PCLZIP_CB_PRE_LIST :
+        case PCLZIP_CB_POST_LIST :
+        */
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          $v_function_name = $p_options_list[$i+1];
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");
+
+          // ----- Check that the value is a valid existing function
+          if (!function_exists($v_function_name)) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+            return PclZip::errorCode();
+          }
+
+          // ----- Set the attribute
+          $v_result_list[$p_options_list[$i]] = $v_function_name;
+          $i++;
+        break;
+
+        default :
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown optional parameter '".$p_options_list[$i]."'");
+
+          // ----- Return
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+          return PclZip::errorCode();
+      }
+
+      // ----- Next options
+      $i++;
+    }
+
+    // ----- Look for mandatory options
+    for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
+      // ----- Look for mandatory option
+      if ($v_requested_options[$key] == 'mandatory') {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
+        // ----- Look if present
+        if (!isset($v_result_list[$key])) {
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
+
+          // ----- Return
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+          return PclZip::errorCode();
+        }
+      }
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privCreate()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privCreate($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
+    $v_result=1;
+    $v_list_detail = array();
+
+    // ----- Open the file in write mode
+    if (($v_result = $this->privOpenFd('wb')) != 1)
+    {
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Add the list of files
+    $v_result = $this->privAddList($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);
+
+    // ----- Close
+    $this->privCloseFd();
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privAdd()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privAdd($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
+    $v_result=1;
+    $v_list_detail = array();
+
+    // ----- Look if the archive exists or is empty
+    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it.");
+
+      // ----- Do a create
+      $v_result = $this->privCreate($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Open the zip file
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
+    if (($v_result=$this->privOpenFd('rb')) != 1)
+    {
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir = array();
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+    {
+      $this->privCloseFd();
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Go to beginning of File
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
+    @rewind($this->zip_fd);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
+
+    // ----- Creates a temporay file
+    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
+
+    // ----- Open the temporary file in write mode
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
+    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
+    {
+      $this->privCloseFd();
+
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Copy the files from the archive to the temporary file
+    // TBC : Here I should better append the file and go back to erase the central dir
+    $v_size = $v_central_dir['offset'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+      $v_buffer = fread($this->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Swap the file descriptor
+    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
+    // the following methods on the temporary fil and not the real archive
+    $v_swap = $this->zip_fd;
+    $this->zip_fd = $v_zip_temp_fd;
+    $v_zip_temp_fd = $v_swap;
+
+    // ----- Add the files
+    $v_header_list = array();
+    if (($v_result = $this->privAddFileList($p_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)
+    {
+      fclose($v_zip_temp_fd);
+      $this->privCloseFd();
+      @unlink($v_zip_temp_name);
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Store the offset of the central dir
+    $v_offset = @ftell($this->zip_fd);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
+
+    // ----- Copy the block of file headers from the old archive
+    $v_size = $v_central_dir['size'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
+      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- 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) {
+          fclose($v_zip_temp_fd);
+          $this->privCloseFd();
+          @unlink($v_zip_temp_name);
+
+          // ----- 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 = '';
+
+    // ----- 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_central_dir['entries'], $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;
+    }
+
+    // ----- Swap back the file descriptor
+    $v_swap = $this->zip_fd;
+    $this->zip_fd = $v_zip_temp_fd;
+    $v_zip_temp_fd = $v_swap;
+
+    // ----- Close
+    $this->privCloseFd();
+
+    // ----- Close the temporary file
+    @fclose($v_zip_temp_fd);
+
+    // ----- Delete the zip file
+    // TBC : I should test the result ...
+    @unlink($this->zipname);
+
+    // ----- Rename the temporary file
+    // TBC : I should test the result ...
+    //@rename($v_zip_temp_name, $this->zipname);
+    PclZipUtilRename($v_zip_temp_name, $this->zipname);
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privOpenFd()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function privOpenFd($p_mode)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode);
+    $v_result=1;
+
+    // ----- Look if already open
+    if ($this->zip_fd != 0)
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Open the zip file
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');
+    if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privCloseFd()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function privCloseFd()
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");
+    $v_result=1;
+
+    if ($this->zip_fd != 0)
+      @fclose($this->zip_fd);
+    $this->zip_fd = 0;
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privAddList()
+  // Description :
+  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
+  //   different from the real path of the file. This is usefull if you want to have PclTar
+  //   running in any directory, and memorize relative path from an other directory.
+  // Parameters :
+  //   $p_list : An array containing the file or directory names to add in the tar
+  //   $p_result_list : list of added files with their properties (specially the status field)
+  //   $p_add_dir : Path to add in the filename path archived
+  //   $p_remove_dir : Path to remove in the filename path archived
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
+    $v_result=1;
+
+    // ----- Add the files
+    $v_header_list = array();
+    if (($v_result = $this->privAddFileList($p_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $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 = '';
+
+    // ----- 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;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privAddFileList()
+  // Description :
+  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
+  //   different from the real path of the file. This is usefull if you want to
+  //   run the lib in any directory, and memorize relative path from an other directory.
+  // Parameters :
+  //   $p_list : An array containing the file or directory names to add in the tar
+  //   $p_result_list : list of added files with their properties (specially the status field)
+  //   $p_add_dir : Path to add in the filename path archived
+  //   $p_remove_dir : Path to remove in the filename path archived
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privAddFileList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
+    $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<count($p_list)) && ($v_result==1); $j++)
+    {
+      // ----- Recuperate the filename
+      $p_filename = PclZipUtilTranslateWinPath($p_list[$j], false);
+
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file [$p_filename]");
+
+      // ----- Skip empty file names
+      if ($p_filename == "")
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");
+        continue;
+      }
+
+      // ----- Check the filename
+      if (!file_exists($p_filename))
+      {
+        // ----- Error log
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '$p_filename' does not exists");
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '$p_filename' does not exists");
+
+        // ----- Return
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+        return PclZip::errorCode();
+      }
+
+      /* This test is done later
+      // ----- Check the path length
+      if (strlen($p_filename) > 0xFF)
+      {
+        // ----- Error log
+        PclZip::privErrorLog(-5, "File name is too long (max. 255) : '$p_filename'");
+
+        // ----- Return
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+        return PclZip::errorCode();
+      }
+      */
+
+      // ----- Look if it is a file or a dir with no all pathnre move
+      if ((is_file($p_filename)) || ((is_dir($p_filename)) && !$p_remove_all_dir)) {
+        // ----- Add the file
+        if (($v_result = $this->privAddFile($p_filename, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)
+        {
+          // ----- Return status
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+          return $v_result;
+        }
+
+        // ----- Store the file infos
+        $p_result_list[$v_nb++] = $v_header;
+      }
+
+      // ----- Look for directory
+      if (is_dir($p_filename))
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "$p_filename is a directory");
+
+        // ----- Look for path
+        if ($p_filename != ".")
+          $v_path = $p_filename."/";
+        else
+          $v_path = "";
+
+        // ----- Read the directory for files and sub-directories
+        $p_hdir = opendir($p_filename);
+        $p_hitem = readdir($p_hdir); // '.' directory
+        $p_hitem = readdir($p_hdir); // '..' directory
+        while ($p_hitem = readdir($p_hdir))
+        {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for $p_hitem in the directory");
+
+          // ----- Look for a file
+          if (is_file($v_path.$p_hitem))
+          {
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the file '".$v_path.$p_hitem."'");
+
+            // ----- Add the file
+            if (($v_result = $this->privAddFile($v_path.$p_hitem, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)
+            {
+              // ----- Return status
+              //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+              return $v_result;
+            }
+
+            // ----- Store the file infos
+            $p_result_list[$v_nb++] = $v_header;
+          }
+
+          // ----- Recursive call to privAddFileList()
+          else
+          {
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the directory '".$v_path.$p_hitem."'");
+
+            // ----- Need an array as parameter
+            $p_temp_list[0] = $v_path.$p_hitem;
+            $v_result = $this->privAddFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);
+
+            // ----- Update the number of elements of the list
+            $v_nb = sizeof($p_result_list);
+          }
+        }
+
+        // ----- Free memory for the recursive loop
+        unset($p_temp_list);
+        unset($p_hdir);
+        unset($p_hitem);
+      }
+    }
+
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have $v_nb elements");
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privAddFile()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privAddFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='$p_filename', add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
+    $v_result=1;
+
+    if ($p_filename == "")
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Calculate the stored filename
+    $v_stored_filename = $p_filename;
+
+    // ----- Look for all path to remove
+    if ($p_remove_all_dir) {
+      $v_stored_filename = basename($p_filename);
+    }
+    // ----- Look for partial path remove
+    else if ($p_remove_dir != "")
+    {
+      if (substr($p_remove_dir, -1) != '/')
+        $p_remove_dir .= "/";
+
+      if ((substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./"))
+      {
+        if ((substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./"))
+          $p_remove_dir = "./".$p_remove_dir;
+        if ((substr($p_filename, 0, 2) != "./") && (substr($p_remove_dir, 0, 2) == "./"))
+          $p_remove_dir = substr($p_remove_dir, 2);
+      }
+
+      $v_compare = PclZipUtilPathInclusion($p_remove_dir, $p_filename);
+      if ($v_compare > 0)
+//      if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)
+      {
+
+        if ($v_compare == 2) {
+          $v_stored_filename = "";
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");
+        }
+        else {
+          $v_stored_filename = substr($p_filename, strlen($p_remove_dir));
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$p_filename' = '$v_stored_filename'");
+        }
+      }
+    }
+    // ----- Look for path to add
+    if ($p_add_dir != "")
+    {
+      if (substr($p_add_dir, -1) == "/")
+        $v_stored_filename = $p_add_dir.$v_stored_filename;
+      else
+        $v_stored_filename = $p_add_dir."/".$v_stored_filename;
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
+    }
+
+    // ----- Filename (reduce the path of stored name)
+    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
+
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Filename (reduced) '$v_stored_filename', strlen ".strlen($v_stored_filename));
+
+    /* filename length moved after call-back in release 1.3
+    // ----- Check the path length
+    if (strlen($v_stored_filename) > 0xFF)
+    {
+      // ----- Error log
+      PclZip::privErrorLog(-5, "Stored file name is too long (max. 255) : '$v_stored_filename'");
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+    */
+
+    // ----- Set the file properties
+    clearstatcache();
+    $p_header['version'] = 20;
+    $p_header['version_extracted'] = 10;
+    $p_header['flag'] = 0;
+    $p_header['compression'] = 0;
+    $p_header['mtime'] = filemtime($p_filename);
+    $p_header['crc'] = 0;
+    $p_header['compressed_size'] = 0;
+    $p_header['size'] = filesize($p_filename);
+    $p_header['filename_len'] = strlen($p_filename);
+    $p_header['extra_len'] = 0;
+    $p_header['comment_len'] = 0;
+    $p_header['disk'] = 0;
+    $p_header['internal'] = 0;
+    $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);
+    $p_header['offset'] = 0;
+    $p_header['filename'] = $p_filename;
+    $p_header['stored_filename'] = $v_stored_filename;
+    $p_header['extra'] = '';
+    $p_header['comment'] = '';
+    $p_header['status'] = 'ok';
+    $p_header['index'] = -1;
+
+    // ----- Look for pre-add callback
+    if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
+      if ($v_result == 0) {
+        // ----- Change the file status
+        $p_header['status'] = "skipped";
+        $v_result = 1;
+      }
+
+      // ----- Update the informations
+      // Only some fields can be modified
+      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
+        $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'");
+      }
+    }
+
+    // ----- Look for empty stored filename
+    if ($p_header['stored_filename'] == "") {
+      $p_header['status'] = "filtered";
+    }
+    
+    // ----- Check the path length
+    if (strlen($p_header['stored_filename']) > 0xFF) {
+      $p_header['status'] = 'filename_too_long';
+    }
+
+    // ----- Look if no error, or file not skipped
+    if ($p_header['status'] == 'ok') {
+
+      // ----- Look for a file
+      if (is_file($p_filename))
+      {
+        // ----- Open the source file
+        if (($v_file = @fopen($p_filename, "rb")) == 0) {
+          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+          return PclZip::errorCode();
+        }
+
+        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
+          // ----- Read the file content
+          $v_content_compressed = @fread($v_file, $p_header['size']);
+
+          // ----- Calculate the CRC
+          $p_header['crc'] = crc32($v_content_compressed);
+        }
+        else {
+          // ----- Read the file content
+          $v_content = @fread($v_file, $p_header['size']);
+
+          // ----- Calculate the CRC
+          $p_header['crc'] = crc32($v_content);
+
+          // ----- Compress the file
+          $v_content_compressed = gzdeflate($v_content);
+        }
+
+        // ----- Set header parameters
+        $p_header['compressed_size'] = strlen($v_content_compressed);
+        $p_header['compression'] = 8;
+
+        // ----- Call the header generation
+        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
+          @fclose($v_file);
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+          return $v_result;
+        }
+
+        // ----- Write the compressed content
+        $v_binary_data = pack('a'.$p_header['compressed_size'], $v_content_compressed);
+        @fwrite($this->zip_fd, $v_binary_data, $p_header['compressed_size']);
+        
+        // ----- Close the file
+        @fclose($v_file);
+      }
+
+      // ----- Look for a directory
+      else
+      {
+        // ----- Set the file properties
+        $p_header['filename'] .= '/';
+        $p_header['filename_len']++;
+        $p_header['size'] = 0;
+        $p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
+
+        // ----- Call the header generation
+        if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
+        {
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+          return $v_result;
+        }
+      }
+    }
+
+    // ----- Look for pre-add callback
+    if (isset($p_options[PCLZIP_CB_POST_ADD])) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
+      if ($v_result == 0) {
+        // ----- Ignored
+        $v_result = 1;
+      }
+
+      // ----- Update the informations
+      // Nothing can be modified
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privWriteFileHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privWriteFileHeader(&$p_header)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
+    $v_result=1;
+
+    // TBC
+    //for(reset($p_header); $key = key($p_header); next($p_header)) {
+    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
+    //}
+
+    // ----- Store the offset position of the file
+    $p_header['offset'] = ftell($this->zip_fd);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);
+
+    // ----- Transform UNIX mtime to DOS format mdate/mtime
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
+    $v_date = getdate($p_header['mtime']);
+    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
+    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
+
+    // ----- Packed data
+    $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version'], $p_header['flag'],
+                          $p_header['compression'], $v_mtime, $v_mdate,
+                          $p_header['crc'], $p_header['compressed_size'], $p_header['size'],
+                          strlen($p_header['stored_filename']), $p_header['extra_len']);
+
+    // ----- Write the first 148 bytes of the header in the archive
+    fputs($this->zip_fd, $v_binary_data, 30);
+
+    // ----- Write the variable fields
+    if (strlen($p_header['stored_filename']) != 0)
+    {
+      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
+    }
+    if ($p_header['extra_len'] != 0)
+    {
+      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privWriteCentralFileHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privWriteCentralFileHeader(&$p_header)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
+    $v_result=1;
+
+    // TBC
+    //for(reset($p_header); $key = key($p_header); next($p_header)) {
+    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
+    //}
+
+    // ----- Transform UNIX mtime to DOS format mdate/mtime
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
+    $v_date = getdate($p_header['mtime']);
+    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
+    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
+
+    // ----- Packed data
+    $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'],
+                          $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'],
+                          $p_header['compressed_size'], $p_header['size'],
+                          strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'],
+                          $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']);
+
+    // ----- Write the 42 bytes of the header in the zip file
+    fputs($this->zip_fd, $v_binary_data, 46);
+
+    // ----- Write the variable fields
+    if (strlen($p_header['stored_filename']) != 0)
+    {
+      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
+    }
+    if ($p_header['extra_len'] != 0)
+    {
+      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
+    }
+    if ($p_header['comment_len'] != 0)
+    {
+      fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privWriteCentralHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"');
+    $v_result=1;
+
+    // ----- Packed data
+    $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment));
+
+    // ----- Write the 22 bytes of the header in the zip file
+    fputs($this->zip_fd, $v_binary_data, 22);
+
+    // ----- Write the variable fields
+    if (strlen($p_comment) != 0)
+    {
+      fputs($this->zip_fd, $p_comment, strlen($p_comment));
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privList()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privList(&$p_list)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");
+    $v_result=1;
+
+    // ----- 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)
+    {
+      // ----- 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)
+    {
+      //--(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']))
+    {
+      // ----- 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)
+      {
+        //--(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();
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privConvertHeader2FileInfo()
+  // Description :
+  //   This function takes the file informations from the central directory
+  //   entries and extract the interesting parameters that will be given back.
+  //   The resulting file infos are set in the array $p_info
+  //     $p_info['filename'] : Filename with full path. Given by user (add),
+  //                           extracted in the filesystem (extract).
+  //     $p_info['stored_filename'] : Stored filename in the archive.
+  //     $p_info['size'] = Size of the file.
+  //     $p_info['compressed_size'] = Compressed size of the file.
+  //     $p_info['mtime'] = Last modification date of the file.
+  //     $p_info['comment'] = Comment associated with the file.
+  //     $p_info['folder'] = true/false : indicates if the entry is a folder or not.
+  //     $p_info['status'] = status of the action on the file.
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privConvertHeader2FileInfo($p_header, &$p_info)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");
+    $v_result=1;
+
+    // ----- Get the interesting attributes
+    $p_info['filename'] = $p_header['filename'];
+    $p_info['stored_filename'] = $p_header['stored_filename'];
+    $p_info['size'] = $p_header['size'];
+    $p_info['compressed_size'] = $p_header['compressed_size'];
+    $p_info['mtime'] = $p_header['mtime'];
+    $p_info['comment'] = $p_header['comment'];
+    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
+    $p_info['index'] = $p_header['index'];
+    $p_info['status'] = $p_header['status'];
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privExtractByRule()
+  // Description :
+  //   Extract a file or directory depending of rules (by index, by name, ...)
+  // Parameters :
+  //   $p_file_list : An array where will be placed the properties of each
+  //                  extracted file
+  //   $p_path : Path to add while writing the extracted files
+  //   $p_remove_path : Path to remove (from the file memorized path) while writing the
+  //                    extracted files. If the path does not match the file path,
+  //                    the file is extracted with its memorized path.
+  //                    $p_remove_path does not apply to 'list' mode.
+  //                    $p_path and $p_remove_path are commulative.
+  // Return Values :
+  //   1 on success,0 or less on error (see error code list)
+  // --------------------------------------------------------------------------------
+  function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
+    $v_result=1;
+
+    // ----- Check the path
+    if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../") && (substr($p_path,1,1)!=":")))
+      $p_path = "./".$p_path;
+
+    // ----- Reduce the path last (and duplicated) '/'
+    if (($p_path != "./") && ($p_path != "/"))
+    {
+      // ----- Look for the path end '/'
+      while (substr($p_path, -1) == "/")
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");
+        $p_path = substr($p_path, 0, strlen($p_path)-1);
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");
+      }
+    }
+
+    // ----- Look for path to remove format (should end by /)
+    if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
+    {
+      $p_remove_path .= '/';
+    }
+    $p_remove_path_size = strlen($p_remove_path);
+
+    // ----- Open the zip file
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
+    if (($v_result = $this->privOpenFd('rb')) != 1)
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir = array();
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+    {
+      // ----- Close the zip file
+      $this->privCloseFd();
+
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Start at beginning of Central Dir
+    $v_pos_entry = $v_central_dir['offset'];
+
+    // ----- Read each entry
+    $j_start = 0;
+    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'");
+
+      // ----- Read next Central dir entry
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'");
+      @rewind($this->zip_fd);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'");
+      if (@fseek($this->zip_fd, $v_pos_entry))
+      {
+        // ----- Close the zip file
+        $this->privCloseFd();
+
+        // ----- 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 after fseek : ".ftell($this->zip_fd)."'");
+
+      // ----- Read the file header
+      $v_header = array();
+      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
+      {
+        // ----- Close the zip file
+        $this->privCloseFd();
+
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+        return $v_result;
+      }
+
+      // ----- Store the index
+      $v_header['index'] = $i;
+
+      // ----- Store the file position
+      $v_pos_entry = ftell($this->zip_fd);
+
+      // ----- Look for the specific extract rules
+      $v_extract = false;
+
+      // ----- Look for extract by name rule
+      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
+          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
+
+          // ----- Look if the filename is in the list
+          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
+
+              // ----- Look for a directory
+              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
+
+                  // ----- Look if the directory is in the filename path
+                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
+                      && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
+                      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
+                      $v_extract = true;
+                  }
+              }
+              // ----- Look for a filename
+              elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
+                  $v_extract = true;
+              }
+          }
+      }
+
+      // ----- Look for extract by ereg rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
+               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
+
+          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
+              $v_extract = true;
+          }
+      }
+
+      // ----- Look for extract by preg rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
+               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
+
+          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
+              $v_extract = true;
+          }
+      }
+
+      // ----- Look for extract by index rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
+               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
+          
+          // ----- Look if the index is in the list
+          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
+
+              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
+                  $v_extract = true;
+              }
+              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
+                  $j_start = $j+1;
+              }
+
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
+                  break;
+              }
+          }
+      }
+
+      // ----- Look for no rule, which means extract all the archive
+      else {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)");
+          $v_extract = true;
+      }
+      
+
+      // ----- Look for real extraction
+      if ($v_extract)
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");
+
+        // ----- Go to the file position
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
+        @rewind($this->zip_fd);
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
+        if (@fseek($this->zip_fd, $v_header['offset']))
+        {
+          // ----- Close the zip file
+          $this->privCloseFd();
+
+          // ----- 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__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
+
+        // ----- Look for extraction as string
+        if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
+
+          // ----- Extracting the file
+          if (($v_result = $this->privExtractFileAsString($v_header, $v_string)) != 1)
+          {
+            // ----- Close the zip file
+            $this->privCloseFd();
+
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+            return $v_result;
+          }
+
+          // ----- Get the only interesting attributes
+          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
+          {
+            // ----- Close the zip file
+            $this->privCloseFd();
+
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+            return $v_result;
+          }
+
+          // ----- Set the file content
+          $p_file_list[$v_nb_extracted]['content'] = $v_string;
+
+          // ----- Next extracted file
+          $v_nb_extracted++;
+        }
+        else {
+          // ----- Extracting the file
+          if (($v_result = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options)) != 1)
+          {
+            // ----- Close the zip file
+            $this->privCloseFd();
+
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+            return $v_result;
+          }
+
+          // ----- Get the only interesting attributes
+          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
+          {
+            // ----- Close the zip file
+            $this->privCloseFd();
+
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+            return $v_result;
+          }
+        }
+      }
+    }
+
+    // ----- Close the zip file
+    $this->privCloseFd();
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privExtractFile()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
+    $v_result=1;
+
+    // ----- Read the file header
+    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
+    // TBC
+
+    // ----- Look for all path to remove
+    if ($p_remove_all_path == true) {
+        // ----- Get the basename of the path
+        $p_entry['filename'] = basename($p_entry['filename']);
+    }
+
+    // ----- Look for path to remove
+    else if ($p_remove_path != "")
+    {
+      //if (strcmp($p_remove_path, $p_entry['filename'])==0)
+      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");
+
+        // ----- Change the file status
+        $p_entry['status'] = "filtered";
+
+        // ----- Return
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+        return $v_result;
+      }
+
+      $p_remove_path_size = strlen($p_remove_path);
+      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");
+
+        // ----- Remove the path
+        $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
+
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");
+      }
+    }
+
+    // ----- Add the path
+    if ($p_path != '')
+    {
+      $p_entry['filename'] = $p_path."/".$p_entry['filename'];
+    }
+
+    // ----- Look for pre-extract callback
+    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
+      if ($v_result == 0) {
+        // ----- Change the file status
+        $p_entry['status'] = "skipped";
+        $v_result = 1;
+      }
+
+      // ----- Update the informations
+      // Only some fields can be modified
+      $p_entry['filename'] = $v_local_header['filename'];
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
+    }
+
+    // ----- Trace
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
+
+    // ----- Look if extraction should be done
+    if ($p_entry['status'] == 'ok') {
+
+    // ----- Look for specific actions while the file exist
+    if (file_exists($p_entry['filename']))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");
+
+      // ----- Look if file is a directory
+      if (is_dir($p_entry['filename']))
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");
+
+        // ----- Change the file status
+        $p_entry['status'] = "already_a_directory";
+
+        // ----- Return
+        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+        //return $v_result;
+      }
+      // ----- Look if file is write protected
+      else if (!is_writeable($p_entry['filename']))
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");
+
+        // ----- Change the file status
+        $p_entry['status'] = "write_protected";
+
+        // ----- Return
+        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+        //return $v_result;
+      }
+
+      // ----- Look if the extracted file is older
+      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");
+
+        // ----- Change the file status
+        $p_entry['status'] = "newer_exist";
+
+        // ----- Return
+        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+        //return $v_result;
+      }
+    }
+
+    // ----- Check the directory availability and create it if necessary
+    else {
+      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
+        $v_dir_to_check = $p_entry['filename'];
+      else if (!strstr($p_entry['filename'], "/"))
+        $v_dir_to_check = "";
+      else
+        $v_dir_to_check = dirname($p_entry['filename']);
+
+      if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");
+
+        // ----- Change the file status
+        $p_entry['status'] = "path_creation_fail";
+
+        // ----- Return
+        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+        //return $v_result;
+        $v_result = 1;
+      }
+    }
+    }
+
+    // ----- Look if extraction should be done
+    if ($p_entry['status'] == 'ok') {
+
+      // ----- Do the extraction (if not a folder)
+      if (!(($p_entry['external']&0x00000010)==0x00000010))
+      {
+
+        // ----- Look for not compressed file
+        if ($p_entry['compressed_size'] == $p_entry['size'])
+        {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
+
+          // ----- Opening destination file
+          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
+          {
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
+
+            // ----- Change the file status
+            $p_entry['status'] = "write_error";
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+            return $v_result;
+          }
+
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
+
+          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+          $v_size = $p_entry['compressed_size'];
+          while ($v_size != 0)
+          {
+            $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");
+            $v_buffer = fread($this->zip_fd, $v_read_size);
+            $v_binary_data = pack('a'.$v_read_size, $v_buffer);
+            @fwrite($v_dest_file, $v_binary_data, $v_read_size);
+            $v_size -= $v_read_size;
+          }
+
+          // ----- Closing the destination file
+          fclose($v_dest_file);
+
+          // ----- Change the file mtime
+          touch($p_entry['filename'], $p_entry['mtime']);
+        }
+        else
+        {
+          // ----- Trace
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
+
+          // ----- Opening destination file
+          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
+
+            // ----- Change the file status
+            $p_entry['status'] = "write_error";
+
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+            return $v_result;
+          }
+
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");
+
+          // ----- Read the compressed file in a buffer (one shot)
+          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
+          
+          // ----- Decompress the file
+          $v_file_content = gzinflate($v_buffer);
+          unset($v_buffer);
+
+          // ----- Write the uncompressed data
+          @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
+          unset($v_file_content);
+
+          // ----- Closing the destination file
+          @fclose($v_dest_file);
+
+          // ----- Change the file mtime
+          touch($p_entry['filename'], $p_entry['mtime']);
+        }
+
+        // ----- Look for chmod option
+        if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");
+
+          // ----- Change the mode of the file
+          chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
+        }
+
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
+      }
+    }
+
+    // ----- Look for post-extract callback
+    if (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privExtractFileAsString()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  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
+    // TBC
+
+    // ----- Trace
+    //--(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']&0x00000010)==0x00000010))
+    {
+      // ----- Look for not compressed file
+      if ($p_entry['compressed_size'] == $p_entry['size'])
+      {
+        // ----- Trace
+        //--(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
+      {
+        // ----- Trace
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
+
+        // ----- Reading the file
+        $v_data = fread($this->zip_fd, $p_entry['compressed_size']);
+        
+        // ----- Decompress the file
+        $p_string = gzinflate($v_data);
+      }
+
+      // ----- 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;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privReadFileHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privReadFileHeader(&$p_header)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");
+    $v_result=1;
+
+    // ----- Read the 4 bytes signature
+    $v_binary_data = @fread($this->zip_fd, 4);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
+    $v_data = unpack('Vid', $v_binary_data);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
+
+    // ----- Check signature
+    if ($v_data['id'] != 0x04034b50)
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Read the first 42 bytes of the header
+    $v_binary_data = fread($this->zip_fd, 26);
+
+    // ----- Look for invalid block size
+    if (strlen($v_binary_data) != 26)
+    {
+      $p_header['filename'] = "";
+      $p_header['status'] = "invalid_header";
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Extract the values
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");
+    $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
+
+    // ----- Get filename
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);
+    $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');
+
+    // ----- Get extra_fields
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);
+    if ($v_data['extra_len'] != 0) {
+      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
+    }
+    else {
+      $p_header['extra'] = '';
+    }
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');
+
+    // ----- Extract properties
+    $p_header['compression'] = $v_data['compression'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.bin2hex($p_header['compression']).'\'');
+    $p_header['size'] = $v_data['size'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');
+    $p_header['compressed_size'] = $v_data['compressed_size'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
+    $p_header['crc'] = $v_data['crc'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.$p_header['crc'].'\'');
+    $p_header['flag'] = $v_data['flag'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');
+
+    // ----- Recuperate date in UNIX format
+    $p_header['mdate'] = $v_data['mdate'];
+    $p_header['mtime'] = $v_data['mtime'];
+    if ($p_header['mdate'] && $p_header['mtime'])
+    {
+      // ----- Extract time
+      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
+      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
+      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
+
+      // ----- Extract date
+      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
+      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
+      $v_day = $p_header['mdate'] & 0x001F;
+
+      // ----- Get UNIX date format
+      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
+
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
+    }
+    else
+    {
+      $p_header['mtime'] = time();
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
+    }
+
+    // ----- Other informations
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compression type : ".$v_data['compression']);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Version : ".$v_data['version']);
+
+    // TBC
+    //for(reset($v_data); $key = key($v_data); next($v_data)) {
+    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);
+    //}
+
+    // ----- Set the stored filename
+    $p_header['stored_filename'] = $p_header['filename'];
+
+    // ----- Set the status field
+    $p_header['status'] = "ok";
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privReadCentralFileHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privReadCentralFileHeader(&$p_header)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");
+    $v_result=1;
+
+    // ----- Read the 4 bytes signature
+    $v_binary_data = @fread($this->zip_fd, 4);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
+    $v_data = unpack('Vid', $v_binary_data);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
+
+    // ----- Check signature
+    if ($v_data['id'] != 0x02014b50)
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Read the first 42 bytes of the header
+    $v_binary_data = fread($this->zip_fd, 42);
+
+    // ----- Look for invalid block size
+    if (strlen($v_binary_data) != 42)
+    {
+      $p_header['filename'] = "";
+      $p_header['status'] = "invalid_header";
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Extract the values
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'");
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'");
+    $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
+
+    // ----- Get filename
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']);
+    if ($p_header['filename_len'] != 0)
+      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
+    else
+      $p_header['filename'] = '';
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\'');
+
+    // ----- Get extra
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']);
+    if ($p_header['extra_len'] != 0)
+      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
+    else
+      $p_header['extra'] = '';
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\'');
+
+    // ----- Get comment
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']);
+    if ($p_header['comment_len'] != 0)
+      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
+    else
+      $p_header['comment'] = '';
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\'');
+
+    // ----- Extract properties
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\'');
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\'');
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.$p_header['crc'].'\'');
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\'');
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\'');
+
+    // ----- Recuperate date in UNIX format
+    if ($p_header['mdate'] && $p_header['mtime'])
+    {
+      // ----- Extract time
+      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
+      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
+      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
+
+      // ----- Extract date
+      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
+      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
+      $v_day = $p_header['mdate'] & 0x001F;
+
+      // ----- Get UNIX date format
+      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
+
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
+    }
+    else
+    {
+      $p_header['mtime'] = time();
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
+    }
+
+    // ----- Set the stored filename
+    $p_header['stored_filename'] = $p_header['filename'];
+
+    // ----- Set default status to ok
+    $p_header['status'] = 'ok';
+
+    // ----- Look if it is a directory
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'");
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')');
+    if (substr($p_header['filename'], -1) == '/')
+    {
+      $p_header['external'] = 0x41FF0010;
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.$p_header['external'].'\'');
+    }
+
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\'');
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privReadEndCentralDir()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privReadEndCentralDir(&$p_central_dir)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");
+    $v_result=1;
+
+    // ----- Go to the end of the zip file
+    $v_size = filesize($this->zipname);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");
+    @fseek($this->zip_fd, $v_size);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');
+    if (@ftell($this->zip_fd) != $v_size)
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- First try : look if this is an archive with no commentaries (most of the time)
+    // in this case the end of central dir is at 22 bytes of the file end
+    $v_found = 0;
+    if ($v_size > 26) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');
+      @fseek($this->zip_fd, $v_size-22);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');
+      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
+      {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
+
+        // ----- Return
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+        return PclZip::errorCode();
+      }
+
+      // ----- Read for bytes
+      $v_binary_data = @fread($this->zip_fd, 4);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
+      $v_data = unpack('Vid', $v_binary_data);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
+
+      // ----- Check signature
+      if ($v_data['id'] == 0x06054b50) {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");
+        $v_found = 1;
+      }
+
+      $v_pos = ftell($this->zip_fd);
+    }
+
+    // ----- Go back to the maximum possible size of the Central Dir End Record
+    if (!$v_found) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');
+      $v_maximum_size = 65557; // 0xFFFF + 22;
+      if ($v_maximum_size > $v_size)
+        $v_maximum_size = $v_size;
+      @fseek($this->zip_fd, $v_size-$v_maximum_size);
+      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
+      {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
+
+        // ----- Return
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+        return PclZip::errorCode();
+      }
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');
+
+      // ----- Read byte per byte in order to find the signature
+      $v_pos = ftell($this->zip_fd);
+      $v_bytes = 0x00000000;
+      while ($v_pos < $v_size)
+      {
+        // ----- Read a byte
+        $v_byte = @fread($this->zip_fd, 1);
+
+        // -----  Add the byte
+        $v_bytes = ($v_bytes << 8) | Ord($v_byte);
+
+        // ----- Compare the bytes
+        if ($v_bytes == 0x504b0506)
+        {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');
+          $v_pos++;
+          break;
+        }
+
+        $v_pos++;
+      }
+
+      // ----- Look if not found end of central dir
+      if ($v_pos == $v_size)
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");
+
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
+
+        // ----- Return
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+        return PclZip::errorCode();
+      }
+    }
+
+    // ----- Read the first 18 bytes of the header
+    $v_binary_data = fread($this->zip_fd, 18);
+
+    // ----- Look for invalid block size
+    if (strlen($v_binary_data) != 18)
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Extract the values
+    ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");
+    ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");
+    $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
+
+    // ----- Check the global size
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);
+    if (($v_pos + $v_data['comment_size'] + 18) != $v_size)
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Fail to find the right signature");
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Fail to find the right signature");
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Get comment
+    if ($v_data['comment_size'] != 0)
+      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
+    else
+      $p_central_dir['comment'] = '';
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');
+
+    $p_central_dir['entries'] = $v_data['entries'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');
+    $p_central_dir['disk_entries'] = $v_data['disk_entries'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');
+    $p_central_dir['offset'] = $v_data['offset'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');
+    $p_central_dir['size'] = $v_data['size'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');
+    $p_central_dir['disk'] = $v_data['disk'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');
+    $p_central_dir['disk_start'] = $v_data['disk_start'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');
+
+    // TBC
+    //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
+    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);
+    //}
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privDeleteByRule()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privDeleteByRule(&$p_result_list, &$p_options)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");
+    $v_result=1;
+    $v_list_detail = array();
+
+    // ----- Open the zip file
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
+    if (($v_result=$this->privOpenFd('rb')) != 1)
+    {
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir = array();
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+    {
+      $this->privCloseFd();
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Go to beginning of File
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
+    @rewind($this->zip_fd);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
+
+    // ----- Scan all the files
+    // ----- Start at beginning of Central Dir
+    $v_pos_entry = $v_central_dir['offset'];
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
+    @rewind($this->zip_fd);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
+    if (@fseek($this->zip_fd, $v_pos_entry))
+    {
+      // ----- Close the zip file
+      $this->privCloseFd();
+
+      // ----- 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__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
+
+    // ----- Read each entry
+    $v_header_list = array();
+    $j_start = 0;
+    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')");
+
+      // ----- Read the file header
+      $v_header_list[$v_nb_extracted] = array();
+      if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
+      {
+        // ----- Close the zip file
+        $this->privCloseFd();
+
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+        return $v_result;
+      }
+
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");
+
+      // ----- Store the index
+      $v_header_list[$v_nb_extracted]['index'] = $i;
+
+      // ----- Look for the specific extract rules
+      $v_found = false;
+
+      // ----- Look for extract by name rule
+      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
+          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
+
+          // ----- Look if the filename is in the list
+          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
+
+              // ----- Look for a directory
+              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
+
+                  // ----- Look if the directory is in the filename path
+                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
+                      && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
+                      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
+                      $v_found = true;
+                  }
+                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
+                          && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
+                      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");
+                      $v_found = true;
+                  }
+              }
+              // ----- Look for a filename
+              elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
+                  $v_found = true;
+              }
+          }
+      }
+
+      // ----- Look for extract by ereg rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
+               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
+
+          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
+              $v_found = true;
+          }
+      }
+
+      // ----- Look for extract by preg rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
+               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
+
+          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
+              $v_found = true;
+          }
+      }
+
+      // ----- Look for extract by index rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
+               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
+
+          // ----- Look if the index is in the list
+          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
+              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
+
+              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
+                  $v_found = true;
+              }
+              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
+                  $j_start = $j+1;
+              }
+
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
+                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
+                  break;
+              }
+          }
+      }
+
+      // ----- Look for deletion
+      if ($v_found)
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted");
+        unset($v_header_list[$v_nb_extracted]);
+      }
+      else
+      {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted");
+        $v_nb_extracted++;
+      }
+    }
+
+    // ----- Look if something need to be deleted
+    if ($v_nb_extracted > 0) {
+
+        // ----- Creates a temporay file
+        $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
+
+        // ----- Creates a temporary zip archive
+        $v_temp_zip = new PclZip($v_zip_temp_name);
+
+        // ----- Open the temporary zip file in write mode
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");
+        if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
+            $this->privCloseFd();
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+            return $v_result;
+        }
+
+        // ----- Look which file need to be kept
+        for ($i=0; $i<sizeof($v_header_list); $i++) {
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'");
+
+            // ----- Calculate the position of the header
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'");
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
+            @rewind($this->zip_fd);
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
+            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
+                // ----- Close the zip file
+                $this->privCloseFd();
+                $v_temp_zip->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- 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__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
+
+            // ----- Read the file header
+            if (($v_result = $this->privReadFileHeader($v_header_list[$i])) != 1) {
+                // ----- Close the zip file
+                $this->privCloseFd();
+                $v_temp_zip->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- Return
+                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+                return $v_result;
+            }
+
+            // ----- Write the file header
+            if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
+                // ----- Close the zip file
+                $this->privCloseFd();
+                $v_temp_zip->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- Return
+                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+                return $v_result;
+            }
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'");
+
+            // ----- Read/write the data block
+            if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
+                // ----- Close the zip file
+                $this->privCloseFd();
+                $v_temp_zip->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- Return
+                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+                return $v_result;
+            }
+        }
+
+        // ----- Store the offset of the central dir
+        $v_offset = @ftell($v_temp_zip->zip_fd);
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset");
+
+        // ----- Re-Create the Central Dir files header
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory");
+        for ($i=0; $i<sizeof($v_header_list); $i++) {
+            // ----- Create the file header
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']);
+            if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
+                $v_temp_zip->privCloseFd();
+                $this->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- Return
+                //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+                return $v_result;
+            }
+
+            // ----- Transform the header to a 'usable' info
+            $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
+        }
+
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer");
+
+        // ----- Zip file comment
+        $v_comment = '';
+
+        // ----- Calculate the size of the central header
+        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
+
+        // ----- Create the central dir footer
+        if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
+            // ----- Reset the file list
+            unset($v_header_list);
+            $v_temp_zip->privCloseFd();
+            $this->privCloseFd();
+            @unlink($v_zip_temp_name);
+
+            // ----- Return
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+            return $v_result;
+        }
+
+        // ----- Close
+        $v_temp_zip->privCloseFd();
+        $this->privCloseFd();
+
+        // ----- Delete the zip file
+        // TBC : I should test the result ...
+        @unlink($this->zipname);
+
+        // ----- Rename the temporary file
+        // TBC : I should test the result ...
+        //@rename($v_zip_temp_name, $this->zipname);
+        PclZipUtilRename($v_zip_temp_name, $this->zipname);
+    
+        // ----- Destroy the temporary archive
+        unset($v_temp_zip);
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privDirCheck()
+  // Description :
+  //   Check if a directory exists, if not it creates it and all the parents directory
+  //   which may be useful.
+  // Parameters :
+  //   $p_dir : Directory path to check.
+  // Return Values :
+  //    1 : OK
+  //   -1 : Unable to create directory
+  // --------------------------------------------------------------------------------
+  function privDirCheck($p_dir, $p_is_dir=false)
+  {
+    $v_result = 1;
+
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");
+
+    // ----- Remove the final '/'
+    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
+    {
+      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
+    }
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");
+
+    // ----- Check the directory availability
+    if ((is_dir($p_dir)) || ($p_dir == ""))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");
+      return 1;
+    }
+
+    // ----- Extract parent directory
+    $p_parent_dir = dirname($p_dir);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");
+
+    // ----- Just a check
+    if ($p_parent_dir != $p_dir)
+    {
+      // ----- Look for parent directory
+      if ($p_parent_dir != "")
+      {
+        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
+        {
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+          return $v_result;
+        }
+      }
+    }
+
+    // ----- Create the directory
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
+    if (!@mkdir($p_dir, 0777))
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privMerge()
+  // Description :
+  //   If $p_archive_to_add does not exist, the function exit with a success result.
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privMerge(&$p_archive_to_add)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");
+    $v_result=1;
+
+    // ----- Look if the archive_to_add exists
+    if (!is_file($p_archive_to_add->zipname))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");
+
+      // ----- Nothing to merge, so merge is a success
+      $v_result = 1;
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Look if the archive exists
+    if (!is_file($this->zipname))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");
+
+      // ----- Do a duplicate
+      $v_result = $this->privDuplicate($p_archive_to_add->zipname);
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Open the zip file
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
+    if (($v_result=$this->privOpenFd('rb')) != 1)
+    {
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir = array();
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+    {
+      $this->privCloseFd();
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Go to beginning of File
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
+    @rewind($this->zip_fd);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
+
+    // ----- Open the archive_to_add file
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");
+    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
+    {
+      $this->privCloseFd();
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir_to_add = array();
+    if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
+    {
+      $this->privCloseFd();
+      $p_archive_to_add->privCloseFd();
+
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Go to beginning of File
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
+    @rewind($p_archive_to_add->zip_fd);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
+
+    // ----- Creates a temporay file
+    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
+
+    // ----- Open the temporary file in write mode
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
+    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
+    {
+      $this->privCloseFd();
+      $p_archive_to_add->privCloseFd();
+
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Copy the files from the archive to the temporary file
+    // TBC : Here I should better append the file and go back to erase the central dir
+    $v_size = $v_central_dir['offset'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+      $v_buffer = fread($this->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Copy the files from the archive_to_add into the temporary file
+    $v_size = $v_central_dir_to_add['offset'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Store the offset of the central dir
+    $v_offset = @ftell($v_zip_temp_fd);
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
+
+    // ----- Copy the block of file headers from the old archive
+    $v_size = $v_central_dir['size'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+      $v_buffer = @fread($this->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Copy the block of file headers from the archive_to_add
+    $v_size = $v_central_dir_to_add['size'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Zip file comment
+    // TBC : I should merge the two comments
+    $v_comment = '';
+
+    // ----- Calculate the size of the (new) central header
+    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
+
+    // ----- Swap the file descriptor
+    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
+    // the following methods on the temporary fil and not the real archive fd
+    $v_swap = $this->zip_fd;
+    $this->zip_fd = $v_zip_temp_fd;
+    $v_zip_temp_fd = $v_swap;
+
+    // ----- Create the central dir footer
+    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
+    {
+      $this->privCloseFd();
+      $p_archive_to_add->privCloseFd();
+      @fclose($v_zip_temp_fd);
+      $this->zip_fd = null;
+
+      // ----- Reset the file list
+      unset($v_header_list);
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Swap back the file descriptor
+    $v_swap = $this->zip_fd;
+    $this->zip_fd = $v_zip_temp_fd;
+    $v_zip_temp_fd = $v_swap;
+
+    // ----- Close
+    $this->privCloseFd();
+    $p_archive_to_add->privCloseFd();
+
+    // ----- Close the temporary file
+    @fclose($v_zip_temp_fd);
+
+    // ----- Delete the zip file
+    // TBC : I should test the result ...
+    @unlink($this->zipname);
+
+    // ----- Rename the temporary file
+    // TBC : I should test the result ...
+    //@rename($v_zip_temp_name, $this->zipname);
+    PclZipUtilRename($v_zip_temp_name, $this->zipname);
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privDuplicate()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privDuplicate($p_archive_filename)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");
+    $v_result=1;
+
+    // ----- Look if the $p_archive_filename exists
+    if (!is_file($p_archive_filename))
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");
+
+      // ----- Nothing to duplicate, so duplicate is a success.
+      $v_result = 1;
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Open the zip file
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
+    if (($v_result=$this->privOpenFd('wb')) != 1)
+    {
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+      return $v_result;
+    }
+
+    // ----- Open the temporary file in write mode
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
+    if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
+    {
+      $this->privCloseFd();
+
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
+
+      // ----- Return
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
+      return PclZip::errorCode();
+    }
+
+    // ----- Copy the files from the archive to the temporary file
+    // TBC : Here I should better append the file and go back to erase the central dir
+    $v_size = filesize($p_archive_filename);
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");
+      $v_buffer = fread($v_zip_temp_fd, $v_read_size);
+      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Close
+    $this->privCloseFd();
+
+    // ----- Close the temporary file
+    @fclose($v_zip_temp_fd);
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privErrorLog()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function privErrorLog($p_error_code=0, $p_error_string='')
+  {
+    if (PCLZIP_ERROR_EXTERNAL == 1) {
+      PclError($p_error_code, $p_error_string);
+    }
+    else {
+      $this->error_code = $p_error_code;
+      $this->error_string = $p_error_string;
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privErrorReset()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function privErrorReset()
+  {
+    if (PCLZIP_ERROR_EXTERNAL == 1) {
+      PclErrorReset();
+    }
+    else {
+      $this->error_code = 1;
+      $this->error_string = '';
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+  }
+  // End of class
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilPathReduction()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function PclZipUtilPathReduction($p_dir)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'");
+    $v_result = "";
+
+    // ----- Look for not empty path
+    if ($p_dir != "")
+    {
+      // ----- Explode path by directory names
+      $v_list = explode("/", $p_dir);
+
+      // ----- Study directories from last to first
+      for ($i=sizeof($v_list)-1; $i>=0; $i--)
+      {
+        // ----- Look for current path
+        if ($v_list[$i] == ".")
+        {
+          // ----- Ignore this directory
+          // Should be the first $i=0, but no check is done
+        }
+        else if ($v_list[$i] == "..")
+        {
+          // ----- Ignore it and ignore the $i-1
+          $i--;
+        }
+        else if (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0))
+        {
+          // ----- Ignore only the double '//' in path,
+          // but not the first and last '/'
+        }
+        else
+        {
+          $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
+        }
+      }
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilPathInclusion()
+  // Description :
+  //   This function indicates if the path $p_path is under the $p_dir tree. Or,
+  //   said in an other way, if the file or sub-dir $p_path is inside the dir
+  //   $p_dir.
+  //   The function indicates also if the path is exactly the same as the dir.
+  //   This function supports path with duplicated '/' like '//', but does not
+  //   support '.' or '..' statements.
+  // Parameters :
+  // Return Values :
+  //   0 if $p_path is not inside directory $p_dir
+  //   1 if $p_path is inside directory $p_dir
+  //   2 if $p_path is exactly the same as $p_dir
+  // --------------------------------------------------------------------------------
+  function PclZipUtilPathInclusion($p_dir, $p_path)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");
+    $v_result = 1;
+
+    // ----- Explode dir and path by directory separator
+    $v_list_dir = explode("/", $p_dir);
+    $v_list_dir_size = sizeof($v_list_dir);
+    $v_list_path = explode("/", $p_path);
+    $v_list_path_size = sizeof($v_list_path);
+
+    // ----- Study directories paths
+    $i = 0;
+    $j = 0;
+    while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");
+
+      // ----- Look for empty dir (path reduction)
+      if ($v_list_dir[$i] == '') {
+        $i++;
+        continue;
+      }
+      if ($v_list_path[$j] == '') {
+        $j++;
+        continue;
+      }
+
+      // ----- Compare the items
+      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");
+        $v_result = 0;
+      }
+
+      // ----- Next items
+      $i++;
+      $j++;
+    }
+
+    // ----- Look if everything seems to be the same
+    if ($v_result) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");
+      // ----- Skip all the empty items
+      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
+      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'");
+
+      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
+        // ----- There are exactly the same
+        $v_result = 2;
+      }
+      else if ($i < $v_list_dir_size) {
+        // ----- The path is shorter than the dir
+        $v_result = 0;
+      }
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilCopyBlock()
+  // Description :
+  // Parameters :
+  //   $p_mode : read/write compression mode
+  //             0 : src & dest normal
+  //             1 : src gzip, dest normal
+  //             2 : src normal, dest gzip
+  //             3 : src & dest gzip
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");
+    $v_result = 1;
+
+    if ($p_mode==0)
+    {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));
+      while ($p_size != 0)
+      {
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+        $v_buffer = @fread($p_src, $v_read_size);
+        @fwrite($p_dest, $v_buffer, $v_read_size);
+        $p_size -= $v_read_size;
+      }
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));
+    }
+    else if ($p_mode==1)
+    {
+      while ($p_size != 0)
+      {
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+        $v_buffer = @gzread($p_src, $v_read_size);
+        @fwrite($p_dest, $v_buffer, $v_read_size);
+        $p_size -= $v_read_size;
+      }
+    }
+    else if ($p_mode==2)
+    {
+      while ($p_size != 0)
+      {
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+        $v_buffer = @fread($p_src, $v_read_size);
+        @gzwrite($p_dest, $v_buffer, $v_read_size);
+        $p_size -= $v_read_size;
+      }
+    }
+    else if ($p_mode==3)
+    {
+      while ($p_size != 0)
+      {
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
+        $v_buffer = @gzread($p_src, $v_read_size);
+        @gzwrite($p_dest, $v_buffer, $v_read_size);
+        $p_size -= $v_read_size;
+      }
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilRename()
+  // Description :
+  //   This function tries to do a simple rename() function. If it fails, it
+  //   tries to copy the $p_src file in a new $p_dest file and then unlink the
+  //   first one.
+  // Parameters :
+  //   $p_src : Old filename
+  //   $p_dest : New filename
+  // Return Values :
+  //   1 on success, 0 on failure.
+  // --------------------------------------------------------------------------------
+  function PclZipUtilRename($p_src, $p_dest)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");
+    $v_result = 1;
+
+    // ----- Try to rename the files
+    if (!@rename($p_src, $p_dest)) {
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");
+
+      // ----- Try to copy & unlink the src
+      if (!@copy($p_src, $p_dest)) {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");
+        $v_result = 0;
+      }
+      else if (!@unlink($p_src)) {
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");
+        $v_result = 0;
+      }
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilOptionText()
+  // Description :
+  //   Translate option value in text. Mainly for debug purpose.
+  // Parameters :
+  //   $p_option : the option value.
+  // Return Values :
+  //   The option text value.
+  // --------------------------------------------------------------------------------
+  function PclZipUtilOptionText($p_option)
+  {
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");
+
+    switch ($p_option) {
+      case PCLZIP_OPT_PATH :
+        $v_result = 'PCLZIP_OPT_PATH';
+      break;
+      case PCLZIP_OPT_ADD_PATH :
+        $v_result = 'PCLZIP_OPT_ADD_PATH';
+      break;
+      case PCLZIP_OPT_REMOVE_PATH :
+        $v_result = 'PCLZIP_OPT_REMOVE_PATH';
+      break;
+      case PCLZIP_OPT_REMOVE_ALL_PATH :
+        $v_result = 'PCLZIP_OPT_REMOVE_ALL_PATH';
+      break;
+      case PCLZIP_OPT_EXTRACT_AS_STRING :
+        $v_result = 'PCLZIP_OPT_EXTRACT_AS_STRING';
+      break;
+      case PCLZIP_OPT_SET_CHMOD :
+        $v_result = 'PCLZIP_OPT_SET_CHMOD';
+      break;
+      case PCLZIP_OPT_BY_NAME :
+        $v_result = 'PCLZIP_OPT_BY_NAME';
+      break;
+      case PCLZIP_OPT_BY_INDEX :
+        $v_result = 'PCLZIP_OPT_BY_INDEX';
+      break;
+      case PCLZIP_OPT_BY_EREG :
+        $v_result = 'PCLZIP_OPT_BY_EREG';
+      break;
+      case PCLZIP_OPT_BY_PREG :
+        $v_result = 'PCLZIP_OPT_BY_PREG';
+      break;
+
+
+      case PCLZIP_CB_PRE_EXTRACT :
+        $v_result = 'PCLZIP_CB_PRE_EXTRACT';
+      break;
+      case PCLZIP_CB_POST_EXTRACT :
+        $v_result = 'PCLZIP_CB_POST_EXTRACT';
+      break;
+      case PCLZIP_CB_PRE_ADD :
+        $v_result = 'PCLZIP_CB_PRE_ADD';
+      break;
+      case PCLZIP_CB_POST_ADD :
+        $v_result = 'PCLZIP_CB_POST_ADD';
+      break;
+
+      default :
+        $v_result = 'Unknown';
+    }
+
+    // ----- Return
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilTranslateWinPath()
+  // Description :
+  //   Translate windows path by replacing '\' by '/' and optionally removing
+  //   drive letter.
+  // Parameters :
+  //   $p_path : path to translate.
+  //   $p_remove_disk_letter : true | false
+  // Return Values :
+  //   The path translated.
+  // --------------------------------------------------------------------------------
+  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
+  {
+    if (stristr(php_uname(), 'windows')) {
+      // ----- Look for potential disk letter
+      if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
+          $p_path = substr($p_path, $v_position+1);
+      }
+      // ----- Change potential windows directory separator
+      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
+          $p_path = strtr($p_path, '\\', '/');
+      }
+    }
+    return $p_path;
+  }
+  // --------------------------------------------------------------------------------
+
+?>