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


PHP SplFileObject::getPathname方法代码示例

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


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

示例1: __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

示例2: _clearDirectory

 /**
  * Clears a directory of cached files with the correct header.
  *
  * @return void
  */
 protected function _clearDirectory($path)
 {
     $dir = new DirectoryIterator($path);
     foreach ($dir as $file) {
         $fileInfo = new SplFileObject($file->getPathname());
         $line = $fileInfo->fgets();
         if (preg_match('#^/\\* asset_compress \\d+ \\*/$#', $line)) {
             $this->out('Deleting ' . $fileInfo->getPathname());
             unlink($fileInfo->getPathname());
         }
     }
 }
开发者ID:sdoney,项目名称:asset_compress,代码行数:17,代码来源:asset_compress.php

示例3: start

 /**
  * @inheritdoc
  */
 public function start()
 {
     if (!$this->file) {
         throw new \LogicException('Set a file first');
     }
     if ($this->writer) {
         throw new \LogicException('Writer already started');
     }
     $this->writer = new BaseXmlWriter();
     $this->writer->openUri($this->file->getPathname());
     $this->writer->setIndent($this->indent);
     $this->writer->startDocument('1.0', 'UTF-8');
     $this->write(sprintf('<%s>', $this->rootNode));
 }
开发者ID:treehouselabs,项目名称:feeder,代码行数:17,代码来源:XmlWriter.php

示例4: _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

示例5: _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

示例6: __construct

 /**
  * @param \SplFileObject $file             File
  * @param string         $sheet            Sheet title (optional)
  * @param string         $type             Excel file type (defaults to Excel2007)
  * @param bool           $prependHeaderRow
  */
 public function __construct(\SplFileObject $file, $sheet = null, $type = 'Excel2007', $prependHeaderRow = false)
 {
     $this->filename = $file->getPathname();
     $this->sheet = $sheet;
     $this->type = $type;
     $this->prependHeaderRow = $prependHeaderRow;
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:13,代码来源:ExcelWriter.php

示例7: __construct

 public function __construct(\SplFileObject $file, $xpath = null)
 {
     $this->filename = $file->getPathname();
     if (!is_null($xpath) && !is_string($xpath)) {
         throw new \InvalidArgumentException('xpath must be null or a string');
     }
     $this->xpath = $xpath;
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:8,代码来源:XmlReader.php

示例8: testInit

 /**
  * @return      void
  */
 public function testInit()
 {
     $filePath = __DIR__ . '/example_read.txt';
     $fileObject = new FileReader($filePath, 'r', true);
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->isReadable());
     $fileObject = new \SplFileObject($filePath, 'r');
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->isReadable());
 }
开发者ID:naucon,项目名称:file,代码行数:13,代码来源:FileReaderTest.php

示例9: testInit

 /**
  * @return      void
  */
 public function testInit()
 {
     $filePath = __DIR__ . '/example_write1.txt';
     $fileObject = new FileWriter($filePath);
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->isWritable());
     $filePath = __DIR__ . '/example_write2.txt';
     $fileObject = new \SplFileObject($filePath, 'r+');
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->isWritable());
 }
开发者ID:naucon,项目名称:file,代码行数:14,代码来源:FileWriterTest.php

示例10: __construct

 public function __construct($message, $parser, \SplFileObject $file = NULL)
 {
     $this->code = xml_get_error_code($parser);
     if (false === $this->code) {
         throw new \BadMethodCallException('This is not a valid xml_parser resource.');
     }
     parent::__construct($message ?: xml_error_string($this->code), $this->code);
     $this->file = $file ? $file->getPathname() : '(data stream)';
     $this->line = xml_get_current_line_number($parser);
     $this->err['srcColumn'] = xml_get_current_column_number($parser);
     $this->err['srcIndex'] = xml_get_current_byte_index($parser);
 }
开发者ID:anrdaemon,项目名称:library,代码行数:12,代码来源:XmlParserError.php

示例11: in

 /**
  * Add input argument
  *
  * @param string $filePath
  *            Input file path
  *
  * @return Identify
  * @throws \InvalidArgumentException
  */
 public function in($filePath)
 {
     if (!file_exists($filePath)) {
         $message = 'The input file path (' . $filePath . ') is invalid or the file could not be located.';
         throw new \InvalidArgumentException($message);
     }
     $file = new \SplFileObject($filePath);
     if ($file->isReadable()) {
         $this->inputFile = '"' . $file->getPathname() . '"';
     }
     $this->getQuery()->dirty();
     return $this;
 }
开发者ID:localgod,项目名称:karla,代码行数:22,代码来源:Identify.php

示例12: __construct

 /**
  * Construct CSV reader
  *
  * @param \SplFileObject $file            Excel file
  * @param int            $headerRowNumber Optional number of header row
  * @param int            $activeSheet     Index of active sheet to read from
  */
 public function __construct(\SplFileObject $file, $headerRowNumber = null, $activeSheet = null)
 {
     $reader = \PHPExcel_IOFactory::createReaderForFile($file->getPathName());
     $reader->setReadDataOnly(true);
     $excel = $reader->load($file->getPathname());
     if (null !== $activeSheet) {
         $excel->setActiveSheetIndex($activeSheet);
     }
     $this->worksheet = $excel->getActiveSheet()->toArray();
     if (null !== $headerRowNumber) {
         $this->setHeaderRowNumber($headerRowNumber);
     }
 }
开发者ID:ngangchill,项目名称:data-import,代码行数:20,代码来源:ExcelReader.php

示例13: testRoutePath

 /**
  * Default route test
  */
 public function testRoutePath()
 {
     $file = new \SplFileObject(__DIR__ . '/../../../../../files/cestlafete.jpg');
     self::$DI['client']->request("GET", "/admin/tests/pathurl/path/", ['path' => $file->getPathname()]);
     $response = self::$DI['client']->getResponse();
     $this->assertTrue($response->isOk());
     $this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
     $content = json_decode(self::$DI['client']->getResponse()->getContent());
     $this->assertTrue(is_object($content));
     $this->assertObjectHasAttribute('exists', $content);
     $this->assertObjectHasAttribute('file', $content);
     $this->assertObjectHasAttribute('dir', $content);
     $this->assertObjectHasAttribute('readable', $content);
     $this->assertObjectHasAttribute('executable', $content);
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:18,代码来源:PathFileTestTest.php

示例14: testShouldRenderDocsActionWhenFileExists

 /**
  * @covers \Phansible\Controller\DefaultController::docsAction
  */
 public function testShouldRenderDocsActionWhenFileExists()
 {
     $container = new \Pimple();
     $this->twig->expects($this->once())->method('render')->with($this->equalTo('docs.html.twig'), $this->callback(function ($param) {
         return array_key_exists('content', $param) && strpos($param['content'], 'ansible');
     }));
     $docFile = new \SplFileObject('/tmp/vagrant.md', 'w+');
     $docFile->fwrite('Phansible');
     $doc = 'vagrant';
     $container['twig'] = $this->twig;
     $container['docs.path'] = '/tmp';
     $this->controller->setPimple($container);
     $this->controller->docsAction($doc);
     unlink($docFile->getPathname());
 }
开发者ID:CipHuK,项目名称:phansible,代码行数:18,代码来源:DefaultControllerTest.php

示例15: __construct

 /**
  * @param \SplFileObject $file            Excel file
  * @param integer        $headerRowNumber Optional number of header row
  * @param integer        $activeSheet     Index of active sheet to read from
  * @param boolean        $readOnly        If set to false, the reader take care of the excel formatting (slow)
  */
 public function __construct(\SplFileObject $file, $headerRowNumber = null, $activeSheet = null, $readOnly = true)
 {
     $reader = \PHPExcel_IOFactory::createReaderForFile($file->getPathName());
     $reader->setReadDataOnly($readOnly);
     /** @var \PHPExcel $excel */
     $excel = $reader->load($file->getPathname());
     if (null !== $activeSheet) {
         $excel->setActiveSheetIndex($activeSheet);
     }
     $this->worksheet = $excel->getActiveSheet();
     $this->maxColumn = $this->worksheet->getHighestColumn();
     $this->maxRow = $this->worksheet->getHighestRow();
     if (null !== $headerRowNumber) {
         $this->setHeaderRowNumber($headerRowNumber);
     }
 }
开发者ID:tegansnyder,项目名称:data-import,代码行数:22,代码来源:ExcelReader.php


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