本文整理汇总了PHP中gzseek函数的典型用法代码示例。如果您正苦于以下问题:PHP gzseek函数的具体用法?PHP gzseek怎么用?PHP gzseek使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gzseek函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: PclTarHandleExtractFile
function PclTarHandleExtractFile($p_tar, &$v_header, $p_path, $p_remove_path, $p_tar_mode)
{
TrFctStart(__FILE__, __LINE__, "PclTarHandleExtractFile", "archive_descr='{$p_tar}', path={$p_path}, remove_path='{$p_remove_path}', tar_mode={$p_tar_mode}");
$v_result = 1;
// TBC : I should replace all $v_tar by $p_tar in this function ....
$v_tar = $p_tar;
$v_extract_file = 1;
$p_remove_path_size = strlen($p_remove_path);
// ----- Look for path to remove
if ($p_remove_path != "" && substr($v_header[filename], 0, $p_remove_path_size) == $p_remove_path) {
TrFctMessage(__FILE__, __LINE__, 3, "Found path '{$p_remove_path}' to remove in file '{$v_header['filename']}'");
// ----- Remove the path
$v_header[filename] = substr($v_header[filename], $p_remove_path_size);
TrFctMessage(__FILE__, __LINE__, 3, "Resulting file is '{$v_header['filename']}'");
}
// ----- Add the path to the file
if ($p_path != "./" && $p_path != "/") {
// ----- Look for the path end '/'
while (substr($p_path, -1) == "/") {
TrFctMessage(__FILE__, __LINE__, 3, "Destination path [{$p_path}] ends by '/'");
$p_path = substr($p_path, 0, strlen($p_path) - 1);
TrFctMessage(__FILE__, __LINE__, 3, "Modified to [{$p_path}]");
}
// ----- Add the path
if (substr($v_header[filename], 0, 1) == "/") {
$v_header[filename] = $p_path . $v_header[filename];
} else {
$v_header[filename] = $p_path . "/" . $v_header[filename];
}
}
// ----- Trace
TrFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '{$v_header['filename']}', size '{$v_header['size']}'");
// ----- Check that the file does not exists
if (file_exists($v_header[filename])) {
TrFctMessage(__FILE__, __LINE__, 2, "File '{$v_header['filename']}' already exists");
// ----- Look if file is a directory
if (is_dir($v_header[filename])) {
TrFctMessage(__FILE__, __LINE__, 2, "Existing file '{$v_header['filename']}' is a directory");
// ----- Change the file status
$v_header[status] = "already_a_directory";
// ----- Skip the extract
$v_extraction_stopped = 1;
$v_extract_file = 0;
} else {
if (!is_writeable($v_header[filename])) {
if (!is_writeable($v_header[filename])) {
TrFctMessage(__FILE__, __LINE__, 2, "Existing file '{$v_header['filename']}' is write protected");
// ----- Change the file status
$v_header[status] = "write_protected";
// ----- Skip the extract
$v_extraction_stopped = 1;
$v_extract_file = 0;
} else {
if (filemtime($v_header[filename]) > $v_header[mtime]) {
TrFctMessage(__FILE__, __LINE__, 2, "Existing file '{$v_header['filename']}' is newer (" . date("l dS of F Y h:i:s A", filemtime($v_header[filename])) . ") than the extracted file (" . date("l dS of F Y h:i:s A", $v_header[mtime]) . ")");
// ----- Change the file status
$v_header[status] = "newer_exist";
// ----- Skip the extract
$v_extraction_stopped = 1;
$v_extract_file = 0;
}
}
}
}
} else {
if ($v_header[typeflag] == "5") {
$v_dir_to_check = $v_header[filename];
} else {
if (!strstr($v_header[filename], "/")) {
$v_dir_to_check = "";
} else {
$v_dir_to_check = dirname($v_header[filename]);
}
}
if (($v_result = PclTarHandlerDirCheck($v_dir_to_check)) != 1) {
TrFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '{$v_header['filename']}'");
// ----- Change the file status
$v_header[status] = "path_creation_fail";
// ----- Skip the extract
$v_extraction_stopped = 1;
$v_extract_file = 0;
}
}
// ----- Do the real bytes extraction (if not a directory)
if ($v_extract_file && $v_header[typeflag] != "5") {
// ----- Open the destination file in write mode
if (($v_dest_file = @fopen($v_header[filename], "wb")) == 0) {
TrFctMessage(__FILE__, __LINE__, 2, "Error while opening '{$v_header['filename']}' in write binary mode");
// ----- Change the file status
$v_header[status] = "write_error";
// ----- Jump to next file
TrFctMessage(__FILE__, __LINE__, 2, "Jump to next file");
if ($p_tar_mode == "tar") {
fseek($v_tar, ftell($v_tar) + ceil($v_header[size] / 512) * 512);
} else {
gzseek($v_tar, gztell($v_tar) + ceil($v_header[size] / 512) * 512);
}
} else {
TrFctMessage(__FILE__, __LINE__, 2, "Start extraction of '{$v_header['filename']}'");
// ----- Read data
//.........这里部分代码省略.........
开发者ID:fedeB-IT-dept,项目名称:fedeB_website,代码行数:101,代码来源:net2ftp_installer.php
示例17: makeBuffer
/**
* Reads in block $this->buffer_block_num of size self::BUFFER_SIZE from
* the archive file
*
* @param string $buffer
* @param bool $return_string
* @return mixed whether successfully read in block or not
*/
function makeBuffer($buffer = "", $return_string = false)
{
if ($buffer == "") {
if (!$this->checkFileHandle()) {
return false;
}
$success = 1;
$seek_pos = $this->buffer_block_num * self::BUFFER_SIZE;
if ($this->compression == "gzip") {
$success = gzseek($this->fh, $seek_pos);
}
if ($this->compression == "plain") {
$success = fseek($this->fh, $seek_pos);
}
if ($success == -1 || !$this->checkFileHandle() || $this->checkEof()) {
return false;
}
if (is_resource($this->buffer_fh)) {
fclose($this->buffer_fh);
}
$padded_buffer_size = self::BUFFER_SIZE + 2 * self::MAX_RECORD_SIZE;
switch ($this->compression) {
case 'bzip2':
$buffer = "";
while (strlen($buffer) < $padded_buffer_size) {
while (!is_string($block = $this->bz2_iterator->nextBlock())) {
if ($this->bz2_iterator->eof()) {
break;
}
}
$buffer .= $block;
if ($this->bz2_iterator->eof()) {
break;
}
}
if ($buffer == "") {
return false;
}
break;
case 'gzip':
$buffer = gzread($this->fh, $padded_buffer_size);
break;
case 'plain':
$buffer = fread($this->fh, $padded_buffer_size);
break;
}
}
if ($return_string) {
return $buffer;
}
file_put_contents($this->buffer_filename, $buffer);
$this->buffer_fh = fopen($this->buffer_filename, "rb");
return true;
}
开发者ID:yakar,项目名称:yioop,代码行数:62,代码来源:text_archive_bundle_iterator.php
示例18: _jumpBlock
function _jumpBlock($p_len = false)
{
if (is_resource($this->_dFile)) {
if ($p_len === false) {
$p_len = 1;
}
if ($this->_bCompress) {
gzseek($this->_dFile, gztell($this->_dFile) + $p_len * 512);
} else {
fseek($this->_dFile, ftell($this->_dFile) + $p_len * 512);
}
}
return true;
}
开发者ID:alex19pov31,项目名称:webenv,代码行数:14,代码来源:bitrixsetup.php
示例19: _seek
function _seek($p_flen, $tell = 0)
{
if ($this->_nomf === TarLib::ARCHIVE_DYNAMIC) {
$this->_memdat = substr($this->_memdat, 0, ($tell ? strlen($this->_memdat) : 0) + $p_flen);
} elseif ($this->_comptype == TarLib::COMPRESS_GZIP) {
@gzseek($this->_fp, ($tell ? @gztell($this->_fp) : 0) + $p_flen);
} elseif ($this->_comptype == TarLib::COMPRESS_BZIP) {
@fseek($this->_fp, ($tell ? @ftell($this->_fp) : 0) + $p_flen);
} else {
@fseek($this->_fp, ($tell ? @ftell($this->_fp) : 0) + $p_flen);
}
}
开发者ID:stretchyboy,项目名称:dokuwiki,代码行数:12,代码来源:TarLib.class.php
示例20: explode
$microtime = explode(" ", microtime());
$starttime = $microtime[0] + $microtime[1];
} else {
$starttime = time();
}
if (file_exists($_GET["fn"] . ".zip")) {
echo "<tr><td><div class=\"bold_left\">" . BI_IMPORTING_FILE . ":</div></td><td>" . basename($_GET["fn"]) . ".zip</td></tr>\n";
} else {
echo "<tr><td><div class=\"bold_left\">" . BI_IMPORTING_FILE . ":</div></td><td>" . basename($_GET["fn"]) . "</td></tr>\n";
}
echo "<tr><td><div class=\"bold_left\">" . BI_INTO_DB . ":</div></td><td>" . $_GET["dbn"] . "</td></tr>\n";
echo "<tr><td><div class=\"bold_left\">" . BI_SESSION_NO . ":</div></td><td>" . $_GET["sn"] . "</td></tr>\n";
echo "<tr><td><div class=\"bold_left\">" . BI_STARTING_LINE . ":</div></td><td>" . $_GET["start"] . "</td></tr>\n";
// start or continue the import process
if (!isset($firstSession)) {
if (gzseek($file, $_GET["foffset"]) != 0) {
$error = "UNEXPECTED ERROR: Can't set gzip file pointer to offset: " . $_GET["foffset"];
}
// execute sql queries
if (!$error) {
extract(PMBP_exec_sql($file, $con, $linespersession), EXTR_OVERWRITE);
}
// get the current file position
if (!$error) {
$foffset = gztell($file);
if ($foffset === false) {
$error = "UNEXPECTED ERROR: Can't read the file pointer offset";
}
}
}
// clean up
开发者ID:wilderguzman,项目名称:lugrawibe,代码行数:31,代码来源:big_import.php
注:本文中的gzseek函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论