當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。