當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SplFileObject::getBaseName方法代碼示例

本文整理匯總了PHP中SplFileObject::getBaseName方法的典型用法代碼示例。如果您正苦於以下問題:PHP SplFileObject::getBaseName方法的具體用法?PHP SplFileObject::getBaseName怎麽用?PHP SplFileObject::getBaseName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SplFileObject的用法示例。


在下文中一共展示了SplFileObject::getBaseName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _setKey

 /**
  * Sets the current cache key this class is managing, and creates a writable SplFileObject
  * for the cache file the key is referring to.
  *
  * @param string $key The key
  * @param bool $createKey Whether the key should be created if it doesn't exists, or not
  * @return bool true if the cache key could be set, false otherwise
  */
 protected function _setKey($key, $createKey = false)
 {
     $groups = null;
     if (!empty($this->_groupPrefix)) {
         $groups = vsprintf($this->_groupPrefix, $this->groups());
     }
     $dir = $this->_config['path'] . $groups;
     if (!is_dir($dir)) {
         mkdir($dir, 0775, true);
     }
     $path = new \SplFileInfo($dir . $key);
     if (!$createKey && !$path->isFile()) {
         return false;
     }
     if (empty($this->_File) || $this->_File->getBaseName() !== $key) {
         $exists = file_exists($path->getPathname());
         try {
             $this->_File = $path->openFile('c+');
         } catch (\Exception $e) {
             trigger_error($e->getMessage(), E_USER_WARNING);
             return false;
         }
         unset($path);
         if (!$exists && !chmod($this->_File->getPathname(), (int) $this->_config['mask'])) {
             trigger_error(sprintf('Could not apply permission mask "%s" on cache file "%s"', $this->_File->getPathname(), $this->_config['mask']), E_USER_WARNING);
         }
     }
     return true;
 }
開發者ID:ripzappa0924,項目名稱:carte0.0.1,代碼行數:37,代碼來源:FileEngine.php

示例2: _openFile

 protected function _openFile($key, $createKey = false)
 {
     $dir = $this->settings['path'];
     //create dir if needed
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $path = new SplFileInfo($dir . $key);
     if (!$createKey && !$path->isFile()) {
         return false;
     }
     if (empty($this->file) || $this->file->getBaseName() !== $key) {
         $exists = file_exists($path->getPathname());
         try {
             $this->file = $path->openFile('c+');
         } catch (Exception $e) {
             if (!$this->settings['suppress_errors']) {
                 trigger_error($e->getMessage(), E_USER_WARNING);
             }
             return false;
         }
         unset($path);
         if (!$exists && !chmod($this->file->getPathname(), (int) $this->settings['mask'])) {
             if (!$this->settings['suppress_errors']) {
                 trigger_error('Could not apply permission mask  on cache file ' . $this->file->getPathname(), E_USER_WARNING);
             }
         }
     }
     return true;
 }
開發者ID:rossaffandy,項目名稱:blockchains.io,代碼行數:30,代碼來源:cache.php


注:本文中的SplFileObject::getBaseName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。