コード例 #1
0
ファイル: pclzip.class.php プロジェクト: SayenkoDesign/ividf
 function privDuplicate($p_archive_filename)
 {
     $v_result = 1;
     // ----- Look if the $p_archive_filename exists
     if (!is_file($p_archive_filename)) {
         // ----- Nothing to duplicate, so duplicate is a success.
         $v_result = 1;
         // ----- Return
         return $v_result;
     }
     // ----- Open the zip file
     if (($v_result = $this->privOpenFd('wb')) != 1) {
         // ----- Return
         return $v_result;
     }
     // ----- Open the temporary file in write mode
     if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) {
         $this->privCloseFd();
         IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \'' . $p_archive_filename . '\' in binary write mode');
         // ----- Return
         return IWPPclZip::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 = iwp_mmb_get_file_size($p_archive_filename);
     while ($v_size != 0) {
         $v_read_size = $v_size < IWP_PCLZIP_READ_BLOCK_SIZE ? $v_size : IWP_PCLZIP_READ_BLOCK_SIZE;
         $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
     return $v_result;
 }