当前位置: 首页>>代码示例>>PHP>>正文


PHP gzseek函数代码示例

本文整理汇总了PHP中gzseek函数的典型用法代码示例。如果您正苦于以下问题:PHP gzseek函数的具体用法?PHP gzseek怎么用?PHP gzseek使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了gzseek函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: readChunk

function readChunk($posx, $posz)
{
    global $REGION_DIR;
    // calculate region file to read
    $regionX = floor($posx / 32);
    $regionZ = floor($posz / 32);
    // open region file, seek to header info
    $file = gzopen($REGION_DIR . "r.{$regionX}.{$regionZ}.mcr", 'r');
    $chunkHeaderLoc = 4 * (floormod($posx, 32) + floormod($posz, 32) * 32);
    gzseek($file, $chunkHeaderLoc);
    $info = unpack('C*', gzread($file, 4));
    $chunkDataLoc = $info[1] << 16 | $info[2] << 8 | $info[3];
    // if chunk hasn't been generated, return empty
    if ($chunkDataLoc == 0) {
        return array();
    }
    // seek to data, write to gz and return
    gzseek($file, $chunkDataLoc * 4096);
    $info = unpack('C*', gzread($file, 4));
    $chunkLength = $info[1] << 32 | $info[2] << 16 | $info[3] << 8 | $info[4];
    // read to skip over compression byte
    gzread($file, 1);
    // skip first two bytes for deflate
    gzread($file, 2);
    // leave off last four bytes for deflate
    $chunkLength -= 4;
    $contents = gzread($file, $chunkLength - 1);
    $contents = gzinflate($contents);
    $data = array_merge(unpack("C*", $contents));
    return $data;
}
开发者ID:runvnc,项目名称:MC-Chunk-Loader,代码行数:31,代码来源:readchunk.php

示例2: extract_file_from_tarball

function extract_file_from_tarball($pkg, $filename, $dest_dir)
{
    global $packages;
    $name = $pkg . '-' . $packages[$pkg];
    $tarball = $dest_dir . "/" . $name . '.tgz';
    $filename = $name . '/' . $filename;
    $destfilename = $dest_dir . "/" . basename($filename);
    $fp = gzopen($tarball, 'rb');
    $done = false;
    do {
        /* read the header */
        $hdr_data = gzread($fp, 512);
        if (strlen($hdr_data) == 0) {
            break;
        }
        $checksum = 0;
        for ($i = 0; $i < 148; $i++) {
            $checksum += ord($hdr_data[$i]);
        }
        for ($i = 148; $i < 156; $i++) {
            $checksum += 32;
        }
        for ($i = 156; $i < 512; $i++) {
            $checksum += ord($hdr_data[$i]);
        }
        $hdr = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $hdr_data);
        $hdr['checksum'] = octdec(trim($hdr['checksum']));
        if ($hdr['checksum'] != $checksum) {
            echo "Checksum for {$tarball} {$hdr['filename']} is invalid\n";
            print_r($hdr);
            return;
        }
        $hdr['size'] = octdec(trim($hdr['size']));
        echo "File: {$hdr['filename']} {$hdr['size']}\n";
        if ($filename == $hdr['filename']) {
            echo "Found the file we want\n";
            $dest = fopen($destfilename, 'wb');
            $x = stream_copy_to_stream($fp, $dest, $hdr['size']);
            fclose($dest);
            echo "Wrote {$x} bytes into {$destfilename}\n";
            break;
        }
        /* skip body of the file */
        $size = 512 * ceil((int) $hdr['size'] / 512);
        echo "Skipping {$size} bytes\n";
        gzseek($fp, gztell($fp) + $size);
    } while (!$done);
}
开发者ID:OTiZ,项目名称:osx,代码行数:48,代码来源:make-pear-bundle.php

示例3: ftell

     $offset = ftell($fp);
 }
 //Header auslesen
 $sline = ReadStatusline($statusline);
 $anzahl_tabellen = $sline['tables'];
 $anzahl_eintraege = $sline['records'];
 $tbl_zeile = '';
 $part = $sline['part'] == '' ? 0 : substr($sline['part'], 3);
 if ($anzahl_eintraege == -1) {
     // not a backup of MySQLDumper
     $tpl->assign_block_vars('NO_MSD_BACKUP', array());
 } else {
     $tabledata = array();
     $i = 0;
     //Tabellenfinos lesen
     gzseek($fp, $offset);
     $eof = false;
     while (!$eof) {
         $line = $gz ? gzgets($fp, 40960) : fgets($fp, 40960);
         if (substr($line, 0, 9) == '-- TABLE|') {
             $d = explode('|', $line);
             $tabledata[$i]['name'] = $d[1];
             $tabledata[$i]['records'] = $d[2];
             $tabledata[$i]['size'] = $d[3];
             $tabledata[$i]['update'] = $d[4];
             $tabledata[$i]['engine'] = isset($d[5]) ? $d[5] : '';
             $i++;
         }
         if (substr($line, 0, 6) == '-- EOF') {
             $eof = true;
         }
开发者ID:robmat,项目名称:samplebator,代码行数:31,代码来源:tabellenabfrage.php

示例4: gzopen_for_read

 private function gzopen_for_read($file, &$warn, &$err)
 {
     if (!function_exists('gzopen') || !function_exists('gzread')) {
         $missing = '';
         if (!function_exists('gzopen')) {
             $missing .= 'gzopen';
         }
         if (!function_exists('gzread')) {
             $missing .= $missing ? ', gzread' : 'gzread';
         }
         $err[] = sprintf(__("Your web server's PHP installation has these functions disabled: %s.", 'updraftplus'), $missing) . ' ' . sprintf(__('Your hosting company must enable these functions before %s can work.', 'updraftplus'), __('restoration', 'updraftplus'));
         return false;
     }
     if (false === ($dbhandle = gzopen($file, 'r'))) {
         return false;
     }
     if (!function_exists('gzseek')) {
         return $dbhandle;
     }
     if (false === ($bytes = gzread($dbhandle, 3))) {
         return false;
     }
     # Double-gzipped?
     if ('H4sI' != base64_encode($bytes)) {
         if (0 === gzseek($dbhandle, 0)) {
             return $dbhandle;
         } else {
             @gzclose($dbhandle);
             return gzopen($file, 'r');
         }
     }
     # Yes, it's double-gzipped
     $what_to_return = false;
     $mess = __('The database file appears to have been compressed twice - probably the website you downloaded it from had a mis-configured webserver.', 'updraftplus');
     $messkey = 'doublecompress';
     $err_msg = '';
     if (false === ($fnew = fopen($file . ".tmp", 'w')) || !is_resource($fnew)) {
         @gzclose($dbhandle);
         $err_msg = __('The attempt to undo the double-compression failed.', 'updraftplus');
     } else {
         @fwrite($fnew, $bytes);
         $emptimes = 0;
         while (!gzeof($dbhandle)) {
             $bytes = @gzread($dbhandle, 131072);
             if (empty($bytes)) {
                 $emptimes++;
                 $this->log("Got empty gzread ({$emptimes} times)");
                 if ($emptimes > 2) {
                     break;
                 }
             } else {
                 @fwrite($fnew, $bytes);
             }
         }
         gzclose($dbhandle);
         fclose($fnew);
         # On some systems (all Windows?) you can't rename a gz file whilst it's gzopened
         if (!rename($file . ".tmp", $file)) {
             $err_msg = __('The attempt to undo the double-compression failed.', 'updraftplus');
         } else {
             $mess .= ' ' . __('The attempt to undo the double-compression succeeded.', 'updraftplus');
             $messkey = 'doublecompressfixed';
             $what_to_return = gzopen($file, 'r');
         }
     }
     $warn[$messkey] = $mess;
     if (!empty($err_msg)) {
         $err[] = $err_msg;
     }
     return $what_to_return;
 }
开发者ID:santikrass,项目名称:apache,代码行数:71,代码来源:class-updraftplus.php

示例5: _jumpBlock

 function _jumpBlock($p_len = null)
 {
     if (is_resource($this->_file)) {
         if ($p_len === null) {
             $p_len = 1;
         }
         if ($this->_compress_type == 'gz') {
             @gzseek($this->_file, @gztell($this->_file) + $p_len * 512);
         } else {
             if ($this->_compress_type == 'bz2') {
                 // ----- Replace missing bztell() and bzseek()
                 for ($i = 0; $i < $p_len; $i++) {
                     $this->_readBlock();
                 }
             } else {
                 if ($this->_compress_type == 'none') {
                     @fseek($this->_file, @ftell($this->_file) + $p_len * 512);
                 } else {
                     $this->_error('Unknown or missing compression type (' . $this->_compress_type . ')');
                 }
             }
         }
     }
     return true;
 }
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:25,代码来源:Archive_Tar.php

示例6: doSeek

 function doSeek($offset, $whence)
 {
     if ($whence == SEEK_SET) {
         $offset = $offset - gztell($this->File);
     } else {
         if ($whence == SEEK_END) {
             eZDebugSetting::writeError('lib-ezfile-gziplibz', "Seeking from end is not supported for gzipped files");
             return false;
         }
     }
     return @gzseek($this->File, $offset);
 }
开发者ID:legende91,项目名称:ez,代码行数:12,代码来源:ezgzipshellcompressionhandler.php

示例7: seek

 /**
  * Seek the file
  *
  * Note: the return value is different to that of fseek
  *
  * @param   integer  $offset  Offset to use when seeking.
  * @param   integer  $whence  Seek mode to use.
  *
  * @return  boolean  True on success, false on failure
  *
  * @see http://php.net/manual/en/function.fseek.php
  * @since   11.1
  */
 public function seek($offset, $whence = SEEK_SET)
 {
     if (!$this->_fh) {
         $this->setError(JText::_('JLIB_FILESYSTEM_ERROR_STREAMS_FILE_NOT_OPEN'));
         return false;
     }
     $retval = false;
     // Capture PHP errors
     $php_errormsg = '';
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     switch ($this->processingmethod) {
         case 'gz':
             $res = gzseek($this->_fh, $offset, $whence);
             break;
         case 'bz':
         case 'f':
         default:
             $res = fseek($this->_fh, $offset, $whence);
             break;
     }
     // Seek, interestingly, returns 0 on success or -1 on failure.
     if ($res == -1) {
         $this->setError($php_errormsg);
     } else {
         $retval = true;
     }
     // Restore error tracking to what it was before
     ini_set('track_errors', $track_errors);
     // Return the result
     return $retval;
 }
开发者ID:jimyb3,项目名称:mathematicalteachingsite,代码行数:45,代码来源:stream.php

示例8: tempnam

$filename = tempnam("/tmp", "phpt");
$fp = fopen($filename, "wb");
fwrite($fp, $original);
var_dump(strlen($original));
var_dump(ftell($fp));
fclose($fp);
$fp = gzopen($filename, "rb");
$data = '';
while ($buf = gzread($fp, 8192)) {
    $data .= $buf;
}
if ($data == $original) {
    echo "Strings are equal\n";
} else {
    echo "Strings are not equal\n";
    var_dump($data);
}
gzseek($fp, strlen($original) / 2);
$data = '';
while ($buf = gzread($fp, 8192)) {
    $data .= $buf;
}
var_dump(strlen($data));
if ($data == substr($original, strlen($original) / 2)) {
    echo "Strings are equal\n";
} else {
    echo "Strings are not equal\n";
    var_dump($data);
}
gzclose($fp);
unlink($filename);
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_zlib_tests_gzreadgzwriteplain.php

示例9: _extractList


//.........这里部分代码省略.........
                     $v_header['filename'] = $p_path . '/' . $v_header['filename'];
                 }
             }
             if (file_exists($v_header['filename'])) {
                 if (@is_dir($v_header['filename']) && $v_header['typeflag'] == '') {
                     $this->_error('File ' . $v_header['filename'] . ' already exists as a directory');
                     return false;
                 }
                 if (is_file($v_header['filename']) && $v_header['typeflag'] == "5") {
                     $this->_error('Directory ' . $v_header['filename'] . ' already exists as a file');
                     return false;
                 }
                 if (!is_writeable($v_header['filename'])) {
                     $this->_error('File ' . $v_header['filename'] . ' already exists and is write protected');
                     return false;
                 }
                 if (filemtime($v_header['filename']) > $v_header['mtime']) {
                     // To be completed : An error or silent no replace ?
                 }
             } elseif (($v_result = $this->_dirCheck($v_header['typeflag'] == "5" ? $v_header['filename'] : dirname($v_header['filename']))) != 1) {
                 $this->_error('Unable to create path for ' . $v_header['filename']);
                 return false;
             }
             if ($v_extract_file) {
                 if ($v_header['typeflag'] == "5") {
                     if (!@file_exists($v_header['filename'])) {
                         if (!@mkdir($v_header['filename'], 0777)) {
                             $this->_error('Unable to create directory {' . $v_header['filename'] . '}');
                             return false;
                         }
                     }
                 } else {
                     if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) {
                         $this->_error('Error while opening {' . $v_header['filename'] . '} in write binary mode');
                         return false;
                     } else {
                         $n = floor($v_header['size'] / 512);
                         for ($i = 0; $i < $n; $i++) {
                             if ($this->_compress) {
                                 $v_content = @gzread($this->_file, 512);
                             } else {
                                 $v_content = @fread($this->_file, 512);
                             }
                             fwrite($v_dest_file, $v_content, 512);
                         }
                         if ($v_header['size'] % 512 != 0) {
                             if ($this->_compress) {
                                 $v_content = @gzread($this->_file, 512);
                             } else {
                                 $v_content = @fread($this->_file, 512);
                             }
                             fwrite($v_dest_file, $v_content, $v_header['size'] % 512);
                         }
                         @fclose($v_dest_file);
                         // ----- Change the file mode, mtime
                         @touch($v_header['filename'], $v_header['mtime']);
                         // To be completed
                         //chmod($v_header[filename], DecOct($v_header[mode]));
                     }
                     // ----- Check the file size
                     clearstatcache();
                     if (filesize($v_header['filename']) != $v_header['size']) {
                         $this->_error('Extracted file ' . $v_header['filename'] . ' does not have the correct file size \'' . filesize($v_filename) . '\' (' . $v_header['size'] . ' expected). Archive may be corrupted.');
                         return false;
                     }
                 }
             } else {
                 // ----- Jump to next file
                 if ($this->_compress) {
                     @gzseek($this->_file, @gztell($this->_file) + ceil($v_header['size'] / 512) * 512);
                 } else {
                     @fseek($this->_file, @ftell($this->_file) + ceil($v_header['size'] / 512) * 512);
                 }
             }
         } else {
             // ----- Jump to next file
             if ($this->_compress) {
                 @gzseek($this->_file, @gztell($this->_file) + ceil($v_header['size'] / 512) * 512);
             } else {
                 @fseek($this->_file, @ftell($this->_file) + ceil($v_header['size'] / 512) * 512);
             }
         }
         if ($this->_compress) {
             $v_end_of_file = @gzeof($this->_file);
         } else {
             $v_end_of_file = @feof($this->_file);
         }
         if ($v_listing || $v_extract_file || $v_extraction_stopped) {
             // ----- Log extracted files
             if (($v_file_dir = dirname($v_header['filename'])) == $v_header['filename']) {
                 $v_file_dir = '';
             }
             if (substr($v_header['filename'], 0, 1) == '/' && $v_file_dir == '') {
                 $v_file_dir = '/';
             }
             $p_list_detail[$v_nb++] = $v_header;
         }
     }
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:sotf,代码行数:101,代码来源:Tar.php

示例10: gzseek

     $restore['tablelock'] = 0;
     $restore['erweiterte_inserts'] = 0;
     if ($sline['tables'] == "-1") {
         $restore['compressed'] ? gzseek($restore['filehandle'], 0) : fseek($restore['filehandle'], 0);
     }
     if ($restore['part'] > 0) {
         WriteLog('Start Multipart-Restore \'' . $restore['filename'] . '\'');
     } else {
         WriteLog('Start Restore \'' . $restore['filename'] . '\'');
     }
 } else {
     if ($restore['compressed'] == 0) {
         $filegroesse = filesize($fpath . $restore['filename']);
     }
     // Dateizeiger an die richtige Stelle setzen
     $restore['compressed'] ? gzseek($restore['filehandle'], $restore['offset']) : fseek($restore['filehandle'], $restore['offset']);
     // Jetzt basteln wir uns mal unsere Befehle zusammen...
     $a = 0;
     $dauer = 0;
     $restore['EOB'] = false;
     //lock_table($restore['actual_table']);
     while ($a < $restore['anzahl_zeilen'] && !$restore['fileEOF'] && $dauer < $restore['max_zeit'] && !$restore['EOB']) {
         $sql_command = get_sqlbefehl();
         if ($sql_command > '') {
             //WriteLog($sql_command);
             $meldung = '';
             $res = mysql_query($sql_command, $config['dbconnection']);
             if (!$res === false) {
                 $anzsql = mysql_affected_rows($config['dbconnection']);
                 // Anzahl der eingetragenen Datensaetze ermitteln (Indexaktionen nicht zaehlen)
                 $command = strtoupper(substr($sql_command, 0, 7));
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:31,代码来源:restore.php

示例11: stream_seek

 public function stream_seek($offset, $whence)
 {
     return gzseek($this->_resource, $offset, $whence);
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:4,代码来源:Gzip.php

示例12: getData

 /**
  * Read data from dictionary.
  *
  * @param int $offset
  * @param int $size
  * @return string
  * @throws DictException When seek operation to offset failed.
  */
 public function getData($offset, $size)
 {
     if ($this->isCompressed) {
         if (($seek = gzseek($this->handle, $offset)) !== -1) {
             $data = gzread($this->handle, $size);
         }
     } else {
         if (($seek = fseek($this->handle, $offset)) !== -1) {
             $data = fread($this->handle, $offset);
         }
     }
     if ($seek === -1) {
         throw new DictException($this, 'File seek error.');
     }
     return $data;
 }
开发者ID:skoro,项目名称:stardict,代码行数:24,代码来源:Dict.php

示例13: jumpBlock

    protected function jumpBlock($p_len=null)
    {
      if (is_resource($this->file)) {
          if ($p_len === null)
              $p_len = 1;

          if ($this->compressType == 'gz') {
              @gzseek($this->file, gztell($this->file)+($p_len*512));
          }
          else if ($this->compressType == 'bz2') {
              // ----- Replace missing bztell() and bzseek()
              for ($i=0; $i<$p_len; $i++)
                  $this->readBlock();
          } else if ($this->compressType == 'none')
              @fseek($this->file, ftell($this->file)+($p_len*512));
          else
              $this->error('Unknown or missing compression type ('
			                .$this->compressType.')');

      }
      return true;
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:22,代码来源:Tar.php

示例14: entrySeek

 public function entrySeek($offset, $whence)
 {
     if (!$this->entryFile) {
         return false;
     }
     return $this->writeMode ? gzseek($this->entryFile, $offset, $whence) : fseek($this->entryFile, $offset, $whence);
 }
开发者ID:vb2005xu,项目名称:BigZip,代码行数:7,代码来源:BigZip.php

示例15: skipbytes

 /**
  * Skip forward in the open file pointer
  *
  * This is basically a wrapper around seek() (and a workaround for bzip2)
  *
  * @param int  $bytes seek to this position
  */
 function skipbytes($bytes)
 {
     if ($this->comptype === Tar::COMPRESS_GZIP) {
         @gzseek($this->fh, $bytes, SEEK_CUR);
     } elseif ($this->comptype === Tar::COMPRESS_BZIP) {
         // there is no seek in bzip2, we simply read on
         @bzread($this->fh, $bytes);
     } else {
         @fseek($this->fh, $bytes, SEEK_CUR);
     }
 }
开发者ID:kevinlovesing,项目名称:dokuwiki,代码行数:18,代码来源:Tar.class.php


注:本文中的gzseek函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。