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


PHP File_Archive::predEreg方法代码示例

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


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

示例1: _readSource

 /**
  * This function performs exactly as readSource, but with two additional parameters
  * ($reachable and $baseDir) that will be set so that $reachable."/".$baseDir == $URL
  * and $reachable can be reached (in case of error)
  *
  * @access private
  */
 function _readSource(&$toConvert, $URL, &$reachable, &$baseDir, $symbolic = null, $uncompression = 0, $directoryDepth = -1)
 {
     $source =& File_Archive::_convertToReader($toConvert);
     if (PEAR::isError($source)) {
         return $source;
     }
     if (is_array($URL)) {
         $converted = array();
         foreach ($URL as $key => $foo) {
             $converted[] =& File_Archive::_convertToReader($URL[$key]);
         }
         return File_Archive::readMulti($converted);
     }
     //No need to uncompress more than $directoryDepth
     //That's not perfect, and some archives will still be uncompressed just
     //to be filtered out :(
     if ($directoryDepth >= 0) {
         $uncompressionLevel = min($uncompression, $directoryDepth);
     } else {
         $uncompressionLevel = $uncompression;
     }
     require_once dirname(__FILE__) . '/Archive/Reader.php';
     $std = File_Archive_Reader::getStandardURL($URL);
     //Modify the symbolic name if necessary
     $slashPos = strrpos($std, '/');
     if ($symbolic === null) {
         if ($slashPos === false) {
             $realSymbolic = $std;
         } else {
             $realSymbolic = substr($std, $slashPos + 1);
         }
     } else {
         $realSymbolic = $symbolic;
     }
     if ($slashPos !== false) {
         $baseFile = substr($std, 0, $slashPos + 1);
         $lastFile = substr($std, $slashPos + 1);
     } else {
         $baseFile = '';
         $lastFile = $std;
     }
     if (strpos($lastFile, '*') !== false || strpos($lastFile, '?') !== false) {
         //We have to build a regexp here
         $regexp = str_replace(array('\\*', '\\?'), array('[^/]*', '[^/]'), preg_quote($lastFile));
         $result = File_Archive::_readSource($source, $baseFile, $reachable, $baseDir, null, 0, -1);
         return File_Archive::filter(File_Archive::predEreg('^' . $regexp . '$'), $result);
     }
     //If the URL can be interpreted as a directory, and we are reading from the file system
     if ((empty($URL) || is_dir($URL)) && $source === null) {
         require_once dirname(__FILE__) . "/Archive/Reader/Directory.php";
         require_once dirname(__FILE__) . "/Archive/Reader/ChangeName.php";
         if ($uncompressionLevel != 0) {
             require_once dirname(__FILE__) . "/Archive/Reader/Uncompress.php";
             $result = new File_Archive_Reader_Uncompress(new File_Archive_Reader_Directory($std, '', $directoryDepth), $uncompressionLevel);
         } else {
             $result = new File_Archive_Reader_Directory($std, '', $directoryDepth);
         }
         if ($directoryDepth >= 0) {
             require_once dirname(__FILE__) . '/Archive/Reader/Filter.php';
             require_once dirname(__FILE__) . '/Archive/Predicate/MaxDepth.php';
             $tmp =& File_Archive::filter(new File_Archive_Predicate_MaxDepth($directoryDepth), $result);
             unset($result);
             $result =& $tmp;
         }
         if (!empty($realSymbolic)) {
             if ($symbolic === null) {
                 $realSymbolic = '';
             }
             $tmp =& new File_Archive_Reader_AddBaseName($realSymbolic, $result);
             unset($result);
             $result =& $tmp;
         }
         //If the URL can be interpreted as a file, and we are reading from the file system
     } else {
         if (is_file($URL) && substr($URL, -1) != '/' && $source === null) {
             require_once dirname(__FILE__) . "/Archive/Reader/File.php";
             $result = new File_Archive_Reader_File($URL, $realSymbolic);
             //Else, we will have to build a complex reader
         } else {
             require_once dirname(__FILE__) . "/Archive/Reader/File.php";
             $realPath = $std;
             // Try to find a file with a known extension in the path (
             // (to manage URLs like archive.tar/directory/file)
             $pos = 0;
             do {
                 if ($pos + 1 < strlen($realPath)) {
                     $pos = strpos($realPath, '/', $pos + 1);
                 } else {
                     $pos = false;
                 }
                 if ($pos === false) {
                     $pos = strlen($realPath);
                 }
//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:Archive.php

示例2: _testRemove

 function _testRemove($extension)
 {
     $writer = File_Archive::toArchive("test.{$extension}", File_Archive::toVariable($x));
     $writer->newFile('foo.txt');
     $writer->writeData('ABCDEF');
     $writer->newFile('bla_to_remove.txt');
     $writer->writeData('GHIJKL');
     $writer->newFile('bar.txt');
     $writer->writeData('MNOP');
     $writer->close();
     File_Archive::removeFromSource(File_Archive::predEreg('_to_remove'), $source = File_Archive::readSource(File_Archive::readMemory($x, "test.{$extension}"), "test.{$extension}/"));
     $this->assertEquals("foo.txt\nbar.txt", implode("\n", $source->getFileList()));
 }
开发者ID:andychang88,项目名称:jianzhanseo.com,代码行数:13,代码来源:test.php


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