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


PHP SplFileObject::getBasename方法代码示例

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


在下文中一共展示了SplFileObject::getBasename方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:Kononenkomg,项目名称:cakephp,代码行数:37,代码来源:FileEngine.php

示例2: __construct

 /**
  * Constructor
  *
  * @param \SplFileObject $post Post source file
  */
 public function __construct(\SplFileObject $post)
 {
     $this->source = $post;
     if (!preg_match('/[\\d]{4}\\/[\\d]{2}\\/(.+)$/', $post->getPathname())) {
         throw new \Exception(sprintf('%s is not a valid post', $post->getPathname()));
     }
     $paths = explode(DIRECTORY_SEPARATOR, $post->getPath());
     $this->month = $paths[count($paths) - 1];
     $this->year = $paths[count($paths) - 2];
     $this->slug = $post->getBasename('.' . $post->getExtension());
 }
开发者ID:jeremyharris,项目名称:build,代码行数:16,代码来源:Post.php

示例3: download

 public function download($path)
 {
     if (is_null($path) || empty($path)) {
         throw new InvalidArgumentException('You must specify the item to download.', 400);
     } else {
         if (!$this->exists($path) || !is_file($this->realRootDirectory . DIRECTORY_SEPARATOR . $path)) {
             throw new FileNotFoundException('The specified file does not exist.', 404);
         }
     }
     $fileObject = new \SplFileObject($this->realRootDirectory . DIRECTORY_SEPARATOR . $path);
     HttpResponse::setContentDisposition($fileObject->getBasename());
     HttpResponse::setContentType('application/octet-stream');
     HttpResponse::setHeader('Content-Length', $fileObject->getSize());
     $fileObject->fpassthru();
     exit(0);
 }
开发者ID:chriswells0,项目名称:cwa-lib,代码行数:16,代码来源:FileManager.php

示例4: checkInstance

 /**
  * @param \SplFileObject $file
  * @param string $namespace
  */
 protected function checkInstance($file, $namespace)
 {
     $class = $namespace . '\\' . $file->getBasename('.php');
     $reflection = new ReflectionClass($class);
     if ($reflection->isSubclassOf('\\Result\\ResultException')) {
         self::getInstance()->pushResult($class);
     }
 }
开发者ID:cronario,项目名称:result,代码行数:12,代码来源:MapBuilder.php

示例5: getFilename

 /**
  * @return string
  */
 public function getFilename()
 {
     return $this->movieFile->getPath() . DIRECTORY_SEPARATOR . $this->movieFile->getBasename();
 }
开发者ID:mihaeu,项目名称:sub-collector,代码行数:7,代码来源:File.php

示例6: SplFileObject

<?php

$file = __FILE__;
$s = new SplFileObject(__FILE__);
echo $s->getBasename();
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:fileobject_getbasename_basic.php

示例7: SplFileObject

<?php

$filePaths = $argv;
array_shift($filePaths);
foreach ($filePaths as $filePath) {
    try {
        $file = new SplFileObject($filePath);
        echo sprintf("%s\n", $file->getBasename());
    } catch (RuntimeException $e) {
        echo sprintf("Unable to open file at path '%s'\n", $filePath);
    }
}
开发者ID:angolaphp,项目名称:learn-you-php,代码行数:12,代码来源:solution.php


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