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


PHP File_Archive::getOption方法代码示例

本文整理汇总了PHP中File_Archive::getOption方法的典型用法代码示例。如果您正苦于以下问题:PHP File_Archive::getOption方法的具体用法?PHP File_Archive::getOption怎么用?PHP File_Archive::getOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File_Archive的用法示例。


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

示例1: next

 /**
  * @see File_Archive_Reader::next()
  */
 function next()
 {
     if (!parent::next()) {
         return false;
     }
     $this->nbRead++;
     $this->filePos = 0;
     if ($this->nbRead > 1) {
         return false;
     }
     $dataFilename = $this->source->getDataFilename();
     if ($dataFilename !== null) {
         $this->tmpName = null;
         $this->gzfile = gzopen($dataFilename, 'r');
     } else {
         $this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
         //Generate the tmp data
         $dest = new File_Archive_Writer_Files();
         $dest->newFile($this->tmpName);
         $this->source->sendData($dest);
         $dest->close();
         $this->gzfile = gzopen($this->tmpName, 'r');
     }
     return true;
 }
开发者ID:ookwudili,项目名称:chisimba,代码行数:28,代码来源:Gzip.php

示例2: next

 /**
  * @see File_Archive_Reader::next()
  */
 function next()
 {
     if (!parent::next()) {
         return false;
     }
     $this->nbRead++;
     if ($this->nbRead > 1) {
         return false;
     }
     $dataFilename = $this->source->getDataFilename();
     if ($dataFilename !== null) {
         $this->tmpName = null;
         $this->bzfile = @bzopen($dataFilename, 'r');
         if ($this->bzfile === false) {
             return PEAR::raiseError("bzopen failed to open {$dataFilename}");
         }
     } else {
         $this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
         //Generate the tmp data
         $dest = new File_Archive_Writer_Files();
         $dest->newFile($this->tmpName);
         $this->source->sendData($dest);
         $dest->close();
         $this->bzfile = bzopen($this->tmpName, 'r');
     }
     return true;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:30,代码来源:Bzip2.php

示例3: newFile

 /**
  * @see File_Archive_Writer::newFile()
  *
  * Check that one single file is written in the GZip archive
  */
 function newFile($filename, $stat = array(), $mime = "application/octet-stream")
 {
     if ($this->nbFiles > 1) {
         return PEAR::raiseError("A Gz archive can only contain one single file." . "Use Tgz archive to be able to write several files");
     }
     $this->nbFiles++;
     $this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
     $this->gzfile = gzopen($this->tmpName, 'w' . $this->compressionLevel);
     return true;
 }
开发者ID:RikaFujiwara,项目名称:NetCommons2,代码行数:15,代码来源:Gzip.php

示例4: getData

 /**
  * @see File_Archive_Reader::getData()
  */
 function getData($length = -1)
 {
     if ($this->fromSource) {
         $data = $this->source->getData($length);
         if (PEAR::isError($data)) {
             return $data;
         }
         fwrite($this->tmpFile, $data);
         return $data;
     } else {
         if ($length == 0) {
             return '';
         }
         if ($length > 0 && $this->pos + 1 < count($this->files)) {
             $maxSize = $this->files[$this->pos + 1]['pos'] - ftell($this->tmpFile);
             if ($maxSize == 0) {
                 return null;
             }
             if ($length > $maxSize) {
                 $length = $maxSize;
             }
             return fread($this->tmpFile, $length);
         } else {
             $contents = '';
             $blockSize = File_Archive::getOption('blockSize');
             while (!feof($this->tmpFile)) {
                 $contents .= fread($this->tmpFile, $blockSize);
             }
             return $contents == '' ? null : $contents;
         }
     }
 }
开发者ID:orcoliver,项目名称:oneye,代码行数:35,代码来源:Cache.php

示例5: sendData

 /**
  * Sends the current file to the Writer $writer
  * The data will be sent by chunks of at most $bufferSize bytes
  * If $bufferSize <= 0 (default), the blockSize option is used
  */
 function sendData(&$writer, $bufferSize = 0)
 {
     if (PEAR::isError($writer)) {
         return $writer;
     }
     if ($bufferSize <= 0) {
         $bufferSize = File_Archive::getOption('blockSize');
     }
     $filename = $this->getDataFilename();
     if ($filename !== null) {
         $error = $writer->writeFile($filename);
         if (PEAR::isError($error)) {
             return $error;
         }
     } else {
         while (($data = $this->getData($bufferSize)) !== null) {
             if (PEAR::isError($data)) {
                 return $data;
             }
             $error = $writer->writeData($data);
             if (PEAR::isError($error)) {
                 return $error;
             }
         }
     }
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:31,代码来源:Reader.php

示例6: appendFile

 function appendFile($filename, $dataFilename)
 {
     //Try to read from the cache
     $cache = File_Archive::getOption('cache', null);
     if ($cache !== null && $this->compressionLevel > 0) {
         $id = realpath($dataFilename);
         $id = urlencode($id);
         $id = str_replace('_', '%5F', $id);
         $group = 'FileArchiveZip' . $this->compressionLevel;
         $mtime = filemtime($dataFilename);
         //Tries to read from cache
         if (($data = $cache->get($id, $group)) !== false) {
             $info = unpack('Vmtime/Vcrc/Vnlength', substr($data, 0, 12));
             $data = substr($data, 12);
         }
         //If cache failed or file modified since then
         if ($data === false || $info['mtime'] != $mtime) {
             $data = file_get_contents($dataFilename);
             $info = array('crc' => crc32($data), 'nlength' => strlen($data), 'mtime' => $mtime);
             $data = gzcompress($data, $this->compressionLevel);
             $data = substr($data, 2, strlen($data) - 6);
             $data = pack('VVV', $info['mtime'], $info['crc'], $info['nlength']) . $data;
             $cache->save($data, $id, $group);
         }
         return $this->appendCompressedData($filename, stat($dataFilename), $data, $info['crc'], $info['nlength']);
     }
     //If no cache system, use the standard way
     return parent::appendFile($filename, $dataFilename);
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:29,代码来源:Zip.php

示例7: appenderFromSource

 /**
  * Create a writer that can be used to append files to an archive inside a source
  * If the archive can't be found in the source, it will be created
  * If source is set to null, File_Archive::toFiles will be assumed
  * If type is set to null, the type of the archive will be determined looking at
  * the extension in the URL
  * stat is the array of stat (returned by stat() PHP function of Reader getStat())
  * to use if the archive must be created
  *
  * This function allows to create or append data to nested archives. Only one
  * archive will be created and if your creation requires creating several nested
  * archives, a PEAR error will be returned
  *
  * After this call, $source will be closed and should not be used until the
  * returned writer is closed.
  *
  * @param File_Archive_Reader $source A reader where some files will be appended
  * @param string $URL URL to reach the archive in the source.
  *        if $URL is null, a writer to append files to the $source reader will
  *        be returned
  * @param bool $unique If true, the duplicate files will be deleted on close
  *        Default is false (and setting it to true may have some performance
  *        consequences)
  * @param string $type Extension of the archive (or null to use the one in the URL)
  * @param array $stat Used only if archive is created, array of stat as returned
  *        by PHP stat function or Reader getStat function: stats of the archive)
  *        Time (index 9) will be overwritten to current time
  * @return File_Archive_Writer a writer that you can use to append files to the reader
  */
 function appenderFromSource(&$toConvert, $URL = null, $unique = null, $type = null, $stat = array())
 {
     $source =& File_Archive::_convertToReader($toConvert);
     if (PEAR::isError($source)) {
         return $source;
     }
     if ($unique == null) {
         $unique = File_Archive::getOption("appendRemoveDuplicates");
     }
     //Do not report the fact that the archive does not exist as an error
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     if ($URL === null) {
         $result =& $source;
     } else {
         if ($type === null) {
             $result = File_Archive::_readSource($source, $URL . '/', $reachable, $baseDir);
         } else {
             $result = File_Archive::readArchive($type, File_Archive::_readSource($source, $URL, $reachable, $baseDir));
         }
     }
     PEAR::popErrorHandling();
     if (!PEAR::isError($result)) {
         if ($unique) {
             require_once dirname(__FILE__) . "/Archive/Writer/UniqueAppender.php";
             return new File_Archive_Writer_UniqueAppender($result);
         } else {
             return $result->makeAppendWriter();
         }
     }
     //The source can't be found and has to be created
     $stat[9] = $stat['mtime'] = time();
     if (empty($baseDir)) {
         if ($source !== null) {
             $writer =& $source->makeWriter();
         } else {
             $writer =& File_Archive::toFiles();
         }
         if (PEAR::isError($writer)) {
             return $writer;
         }
         PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
         $result = File_Archive::toArchive($reachable, $writer, $type);
         PEAR::popErrorHandling();
         if (PEAR::isError($result)) {
             $result = File_Archive::toFiles($reachable);
         }
     } else {
         $reachedSource = File_Archive::readSource($source, $reachable);
         if (PEAR::isError($reachedSource)) {
             return $reachedSource;
         }
         $writer = $reachedSource->makeWriter();
         if (PEAR::isError($writer)) {
             return $writer;
         }
         PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
         $result = File_Archive::toArchive($baseDir, $writer, $type);
         PEAR::popErrorHandling();
         if (PEAR::isError($result)) {
             require_once dirname(__FILE__) . "/Archive/Writer/AddBaseName.php";
             $result = new File_Archive_Writer_AddBaseName($baseDir, $writer);
             if (PEAR::isError($result)) {
                 return $result;
             }
         }
     }
     return $result;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:97,代码来源:Archive.php

示例8: getData

 /**
  * @see File_Archive_Reader::getData()
  */
 function getData($length = -1)
 {
     $error = $this->_ensureFileOpened();
     if (PEAR::isError($error)) {
         return $error;
     }
     if (feof($this->handle)) {
         return null;
     }
     if ($length == -1) {
         $contents = '';
         $blockSize = File_Archive::getOption('blockSize');
         while (!feof($this->handle)) {
             $contents .= fread($this->handle, $blockSize);
         }
         return $contents;
     } else {
         if ($length == 0) {
             return "";
         } else {
             return fread($this->handle, $length);
         }
     }
 }
开发者ID:RikaFujiwara,项目名称:NetCommons2,代码行数:27,代码来源:File.php

示例9: ensureDataExtracted

 /**
  * Ensure data has been extracted to $this->entryTmpName
  */
 function ensureDataExtracted()
 {
     if ($this->fileReader !== null) {
         return;
     }
     if ($this->entryTmpName === null) {
         $this->entryTmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
     }
     $this->rarEntry->extract(false, $this->entryTmpName);
     $this->fileReader = new File_Archive_Reader_File($this->entryTmpName, $this->rarEntry->getName());
 }
开发者ID:orcoliver,项目名称:oneye,代码行数:14,代码来源:Rar.php

示例10: getData

 /**
  * @see File_Archive_Reader::getData()
  */
 function getData($length = -1)
 {
     $error = $this->_ensureFileOpened();
     if (PEAR::isError($error)) {
         return $error;
     }
     if (feof($this->handle)) {
         return null;
     }
     if ($length == -1) {
         $contents = '';
         $blockSize = File_Archive::getOption('blockSize');
         // Ensure that magic_quote_runtime isn't set,
         // if we don't want to have corrupted archives.
         $saveMagicQuotes = get_magic_quotes_runtime();
         @set_magic_quotes_runtime(0);
         while (!feof($this->handle)) {
             $contents .= fread($this->handle, $blockSize);
         }
         @set_magic_quotes_runtime($saveMagicQuotes);
         return $contents;
     } else {
         if ($length == 0) {
             return "";
         } else {
             return fread($this->handle, $length);
         }
     }
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:32,代码来源:File.php


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