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


PHP Path::exists方法代码示例

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


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

示例1: index

 public static function index(Path $path, $levels = null, &$count = 0)
 {
     printf("Indexing: %s\n", $path->getRelative());
     if (preg_match("/^\\.in\\./", $path->getFilename())) {
         return;
     }
     try {
         $record = $path->loadRecord();
         // if this path does not exist, and we have a record then delete it
         if (!$path->exists()) {
             if ($record) {
                 $record->delete();
             }
             return;
         }
         if (!$record) {
             // none exists, create it
             $path->loadCreateRecord();
             $count++;
         } else {
             // it exists, check if it needs updating
             if ($record->checkUpdate($path)) {
                 $count++;
             }
         }
         // index children
         if ($levels > 0 || $levels === null) {
             if ($levels !== null) {
                 $levels--;
             }
             if ($path->isDir()) {
                 $children = $path->getChildren();
                 foreach ($children as $child) {
                     self::index($child, $levels, $count);
                 }
             }
         }
     } catch (Exception $e) {
         print (string) $e;
         Log::error($e, array('path' => $path->getRelative()));
     }
 }
开发者ID:qqueue,项目名称:MangaIndex,代码行数:42,代码来源:Indexer.php

示例2: exists

 public function exists()
 {
     return Path::exists($this->path);
 }
开发者ID:vbessonov,项目名称:fsrapi,代码行数:4,代码来源:FileSystemInfo.php

示例3: listdir

 /**
  * Returns content of directory.
  *
  * If $split == true, Path::listdir returns flat array with mixed
  * files and directories.
  * Otherwise, return 2-element associative array, with keys: 'files'
  * and 'dirs'.
  *
  * Return doesn't include 'dots' ('.' and '..').
  *
  * @param string  $dir   directory to scan
  * @param string  $order Path::SORT_ASC or Path::SORT_DESC
  * @param boolean $split 
  *
  * @return array
  * @throws CENotFound ({@link CENotFound description})
  *
  * @access public
  */
 public static function listdir($dir, $order = self::SORT_ASC, $split = false)
 {
     $dir = Path::real($dir);
     if (!Path::exists($dir)) {
         throw new CENotFound(sprintf('Directory "%s" not found.', $dir));
     }
     $files = array();
     $dirs = array();
     $d = dir($dir);
     while (false !== ($obj = $d->read())) {
         if (in_array($obj, array('.', '..'))) {
             continue;
         }
         $path = Path::join($dir, $obj);
         if (is_link($path)) {
             $path = readlink($path);
             $obj = basename($path);
         }
         if (is_file($path)) {
             $files[] = $obj;
         } else {
             if (is_dir($path)) {
                 $dirs[] = $obj;
             }
         }
     }
     if (!$split) {
         $ret = array_merge($files, $dirs);
         switch ($order) {
             case self::SORT_ASC:
                 sort($ret, SORT_STRING);
                 break;
             case self::SORT_DESC:
                 rsort($ret, SORT_STRING);
                 break;
         }
     } else {
         switch ($order) {
             case self::SORT_ASC:
                 sort($files);
                 sort($dirs);
                 break;
             case self::SORT_DESC:
                 rsort($files);
                 rsort($dirs);
                 break;
         }
         $ret = array('files' => $files, 'dirs' => $dirs);
     }
     return $ret;
 }
开发者ID:BackupTheBerlios,项目名称:core-svn,代码行数:70,代码来源:ns_path.php


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