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


PHP SplFileObject::getRealPath方法代码示例

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


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

示例1: read

 /**
  * {@inheritdoc}
  */
 public function read()
 {
     if (null === $this->csv) {
         if (mime_content_type($this->filePath) === 'application/zip') {
             $this->extractZipArchive();
         }
         $this->csv = new \SplFileObject($this->filePath);
         $this->csv->setFlags(\SplFileObject::READ_CSV | \SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY | \SplFileObject::DROP_NEW_LINE);
         $this->csv->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
         $this->fieldNames = $this->csv->fgetcsv();
     }
     $data = $this->csv->fgetcsv();
     if (false !== $data) {
         if ($data === array(null) || $data === null) {
             return null;
         }
         if ($this->stepExecution) {
             $this->stepExecution->incrementSummaryInfo('read');
         }
         if (count($this->fieldNames) !== count($data)) {
             throw new InvalidItemException('pim_base_connector.steps.csv_reader.invalid_item_columns_count', $data, array('%totalColumnsCount%' => count($this->fieldNames), '%itemColumnsCount%' => count($data), '%csvPath%' => $this->csv->getRealPath(), '%lineno%' => $this->csv->key()));
         }
         $data = array_combine($this->fieldNames, $data);
     } else {
         throw new \RuntimeException('An error occured while reading the csv.');
     }
     return $data;
 }
开发者ID:NoelCamille,项目名称:pim-community-dev,代码行数:31,代码来源:CsvReader.php

示例2: buildQueue

 protected function buildQueue()
 {
     $projectDir = $this->getProjectDir();
     $outputDir = $this->getOutputDir();
     $item = new \SplFileObject($this->getSingleFile());
     if ($item->isFile()) {
         try {
             $factory = new View\Factory($item->getRealPath());
             $view = $factory->create();
             $view->setSiteConfig($this->getSiteConfig())->setOutputDir($outputDir);
             $this->addView($view);
         } catch (\Exception $e) {
             $this->getOutputter()->stderr(str_replace($projectDir, '', $item->getRealPath()) . ': ' . $e->getMessage());
         }
     }
     return $this;
 }
开发者ID:lordelph,项目名称:phrekyll,代码行数:17,代码来源:PieceOfSite.php

示例3: testParseFile

 public function testParseFile()
 {
     $content = 'test';
     $fileObject = new \SplFileObject(tempnam(sys_get_temp_dir(), 'test_'), 'w+');
     $fileObject->fwrite($content);
     $parserMock = $this->getMockForAbstractClass($this->parserClassName, array(), '', true, true, true, array('parseContent'));
     $parserMock->expects($this->once())->method('parseContent')->with($this->equalTo($content))->will($this->returnArgument(0));
     $this->assertSame($content, $parserMock->parseFile($fileObject->getRealPath()));
 }
开发者ID:jakubzapletal,项目名称:bank-statements,代码行数:9,代码来源:XMLParserTest.php

示例4: testSetWhereValueSetIsntAsLongAsSlice

 public function testSetWhereValueSetIsntAsLongAsSlice()
 {
     $fileObject = new \SplFileObject(__DIR__ . '/Fixtures/lazy_line_' . $this->getFaker()->word . '.txt', 'w+');
     $fileObject->fwrite(str_repeat(' ', 10));
     $fileObject->fwrite("\n");
     $fileObject->fwrite(str_repeat(' ', 10));
     $line = new FileSystemLine($fileObject, 11, 10);
     $line['0:5'] = 'we';
     $this->assertEquals('we        ', (string) $line);
     unlink($fileObject->getRealPath());
 }
开发者ID:SaveYa,项目名称:FixedWidth,代码行数:11,代码来源:FileSystemLineTest.php

示例5: delete

 /**
  * Delete a key from the cache
  *
  * @param string $key Identifier for the data
  * @return bool True if the value was successfully deleted, false if it didn't
  *   exist or couldn't be removed
  */
 public function delete($key)
 {
     $key = $this->_key($key);
     if ($this->_setKey($key) === false || !$this->_init) {
         return false;
     }
     $path = $this->_File->getRealPath();
     $this->_File = null;
     //@codingStandardsIgnoreStart
     return @unlink($path);
     //@codingStandardsIgnoreEnd
 }
开发者ID:Mingyangzu,项目名称:PHP-cakephp,代码行数:19,代码来源:FileEngine.php

示例6: addCoverageFromFile

 /**
  * Adds the coverage contained in $coverageFile and deletes the file afterwards
  * @param string $coverageFile Code coverage file
  * @throws \RuntimeException When coverage file is empty
  */
 public function addCoverageFromFile($coverageFile)
 {
     if ($coverageFile === null || !file_exists($coverageFile)) {
         return;
     }
     $file = new \SplFileObject($coverageFile);
     if (0 === $file->getSize()) {
         throw new \RuntimeException("Coverage file {$file->getRealPath()} is empty. This means a PHPUnit process has crashed.");
     }
     $this->addCoverage($this->getCoverageObject($file));
     unlink($file->getRealPath());
 }
开发者ID:brianium,项目名称:paratest,代码行数:17,代码来源:CoverageMerger.php

示例7: __construct

	/**
	 * Construct a new file object and set defaults.
	 *
	 * @param string $file
	 * @param string $mode
	 * @param bool $include
	 * @param stream $context
	 * @return Interspire_File
	 */
	public function __construct($file, $mode = 'r', $include = false, $context = null)
	{
		if ($context) {
			parent::__construct($file, $mode, $include, $context);
		}
		else {
			parent::__construct($file, $mode, $include);
		}

		if (method_exists('SplFileObject', 'getRealPath')) {
			// getRealPath is PHP >= 5.2.2
			$this->realpath = parent::getRealPath();
		} else {
			$this->realpath = realpath($file);
		}
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:25,代码来源:File.php

示例8: purgeAll

 public function purgeAll($check_expiry = false)
 {
     if (!$this->is_init) {
         return false;
     }
     $dir = dir($this->settings['path']);
     if ($check_expiry) {
         if (is_numeric($check_expiry)) {
             $now = $check_expiry;
         } else {
             $now = time();
         }
         $threshold = $now - $this->settings['cache_duration'];
     }
     $prefixLength = strlen($this->settings['key_prefix']);
     while (($entry = $dir->read()) !== false) {
         if (substr($entry, 0, $prefixLength) !== $this->settings['key_prefix']) {
             continue;
         }
         if ($this->_openFile($entry) === false) {
             continue;
         }
         if ($check_expiry) {
             $mtime = $this->file->getMTime();
             if ($mtime > $threshold) {
                 continue;
             }
             $expires = (int) $this->file->current();
             if ($expires > $now) {
                 continue;
             }
         }
         $path = $this->file->getRealPath();
         $this->file = null;
         if (file_exists($path)) {
             unlink($path);
         }
     }
     $dir->close();
     return true;
 }
开发者ID:rossaffandy,项目名称:blockchains.io,代码行数:41,代码来源:cache.php

示例9: read

 /**
  * {@inheritdoc}
  */
 public function read()
 {
     if (null === $this->csv) {
         $this->initializeRead();
     }
     $data = $this->csv->fgetcsv();
     if (false !== $data) {
         if ([null] === $data || null === $data) {
             return null;
         }
         if ($this->stepExecution) {
             $this->stepExecution->incrementSummaryInfo('read_lines');
         }
         if (count($this->fieldNames) !== count($data)) {
             throw new InvalidItemException('pim_connector.steps.csv_reader.invalid_item_columns_count', $data, ['%totalColumnsCount%' => count($this->fieldNames), '%itemColumnsCount%' => count($data), '%csvPath%' => $this->csv->getRealPath(), '%lineno%' => $this->csv->key()]);
         }
         $data = array_combine($this->fieldNames, $data);
     } else {
         throw new \RuntimeException('An error occurred while reading the csv.');
     }
     return $data;
 }
开发者ID:CopeX,项目名称:pim-community-dev,代码行数:25,代码来源:CsvReader.php

示例10: _clearDirectory

 /**
  * Used to clear a directory of matching files.
  *
  * @param string $path The path to search.
  * @param integer $now The current timestamp
  * @param integer $threshold Any file not modified after this value will be deleted.
  * @return void
  */
 protected function _clearDirectory($path, $now, $threshold)
 {
     $prefixLength = strlen($this->settings['prefix']);
     if (!is_dir($path)) {
         return;
     }
     $dir = dir($path);
     while (($entry = $dir->read()) !== false) {
         if (substr($entry, 0, $prefixLength) !== $this->settings['prefix']) {
             continue;
         }
         $filePath = $path . $entry;
         if (!file_exists($filePath) || is_dir($filePath)) {
             continue;
         }
         $file = new SplFileObject($path . $entry, 'r');
         if ($threshold) {
             $mtime = $file->getMTime();
             if ($mtime > $threshold) {
                 continue;
             }
             $expires = (int) $file->current();
             if ($expires > $now) {
                 continue;
             }
         }
         if ($file->isFile()) {
             $filePath = $file->getRealPath();
             $file = null;
             //@codingStandardsIgnoreStart
             @unlink($filePath);
             //@codingStandardsIgnoreEnd
         }
     }
 }
开发者ID:jrbasso,项目名称:cakephp,代码行数:43,代码来源:FileEngine.php

示例11: purge

 /**
  * @return bool
  */
 public function purge()
 {
     // no unlink because there's an add after that requires the file to exist
     return file_put_contents($this->file->getRealPath(), '');
 }
开发者ID:ratibus,项目名称:pflow,代码行数:8,代码来源:File.php

示例12: getResource

 /**
  * Get the full path to a file located in the tests resources
  * @param string $relativePath
  * @return string
  */
 public function getResource($relativePath)
 {
     $file = new \SplFileObject($relativePath, 'rb', true);
     return $file->getRealPath();
 }
开发者ID:nuxeo,项目名称:nuxeo-automation-php-client,代码行数:10,代码来源:NuxeoTestCase.php

示例13: SplFileObject

<?php

set_include_path('tests');
chdir(dirname(dirname(__FILE__)));
// ext/spl
$fo = new SplFileObject('fileobject_004.phpt', 'r', true);
var_dump($fo->getPath());
var_dump($fo->getFilename());
var_dump($fo->getRealPath());
?>
==DONE==
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:fileobject_004.php

示例14: getComposerLockData

 /**
  * Reads and decodes json from given file.
  *
  * @param \SplFileObject $file
  * @return mixed
  */
 private function getComposerLockData(\SplFileObject $file)
 {
     $json = file_get_contents($file->getRealPath());
     return json_decode($json);
 }
开发者ID:joska,项目名称:satisfy,代码行数:11,代码来源:LockProcessor.php

示例15: divideCSVFile

 /**
  * Divide large CSV file into several parts and return list of part files
  *
  * @param \SplFileObject $file File object
  *
  * @return array
  */
 public function divideCSVFile($file)
 {
     $result = array();
     $outputFileFormat = basename($file->getRealPath());
     $f = fopen($file->getRealPath(), 'rb');
     // Part file index
     $fi = 1;
     // Row index
     $i = 0;
     $ip = 0;
     // Delta (sum of rows in all previous part files)
     $delta = 0;
     $content = '';
     $pendingContent = '';
     $columns = $this->getKeyColumns();
     // Subdirectory of tmp dir to write CSV part files
     $subDir = time();
     while (true) {
         $fields = fgetcsv($f, 0, ',', '"');
         if (false !== $fields && 1 === count($fields) && null === $fields[0]) {
             // Skip blank lines
             continue;
         }
         if (null === $header) {
             // Initialize header
             $this->processHeaderRow(array($fields));
             $header = $this->getCSVString($fields);
             continue;
         }
         $save = false;
         if (false !== $fields) {
             // Get current row content
             $currentRow = $this->getCSVString($fields);
             $isSubrow = true;
             if (!empty($prevFields)) {
                 // Check if next line is subrow of current
                 $isEmpty = true;
                 foreach ($columns as $column) {
                     $prevKey = $this->getColumnValue($column, $prevFields);
                     $isEmpty = $isEmpty && !(bool) $prevKey;
                     if (!$isEmpty && $prevKey !== $this->getColumnValue($column, $fields)) {
                         $isSubrow = false;
                         break;
                     }
                 }
                 $isSubrow = $isEmpty ? false : $isSubrow;
             } else {
                 $isSubrow = false;
             }
             if (!$isSubrow) {
                 $prevFields = $fields;
             }
             // Prepare content
             if ($isSubrow) {
                 // Current row is a subrow or one of previous rows - add this to $pendingContent
                 $pendingContent .= $currentRow;
                 $ip++;
             } else {
                 // Current row is a complete row - merge $pendingContent into $content...
                 $content .= $pendingContent;
                 $i += $ip;
                 // ...then initialize $pendingContent with current row value
                 $pendingContent = $currentRow;
                 $ip = 1;
             }
             if ($i >= static::MAX_PART_FILE_ROWS && $content) {
                 $save = true;
             }
         }
         if ($save || false === $fields) {
             $outputFile = LC_DIR_TMP . $subDir . LC_DS . preg_replace('/(\\.csv)$/', sprintf('.part-%02d.csv', $fi++), $outputFileFormat);
             if (!\Includes\Utils\FileManager::write($outputFile, $header . $content)) {
                 \XLite\Logger::getInstance()->log('Cannot write file ' . $outputFile);
                 $result = array();
                 break;
             }
             $result[] = array('file' => $outputFile, 'delta' => $delta);
             $delta += $i;
             $i = 0;
             $content = '';
         }
         if (false === $fields) {
             break;
         }
     }
     // while
     return $result;
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:95,代码来源:AProcessor.php


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