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


PHP SplFileObject::getFilename方法代码示例

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


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

示例1: getFilename

 /**
  * Returns the source filename for where the comment block was located
  *
  * @return string
  */
 public function getFilename()
 {
     if ($this->file === null) {
         return '';
     }
     return $this->file->getFilename();
 }
开发者ID:benmanu,项目名称:silverstripe-styleguide,代码行数:12,代码来源:Section.php

示例2: find

 public static function find($fileArray)
 {
     $return = [];
     foreach ($fileArray as $file) {
         $file = new \SplFileObject($file);
         $return[] = substr($file->getFilename(), 0, strlen($file->getFilename()) - (strlen($file->getExtension()) + 1));
     }
     return $return;
 }
开发者ID:oyoy8629,项目名称:yii-core,代码行数:9,代码来源:FileHelper.php

示例3: onCreateArchive

 /**
  * @param ExportEventInterface $event
  * @throws CloseArchiveException
  * @throws OpenArchiveException
  * @throws UnavailableArchiveException
  */
 public function onCreateArchive(ExportEventInterface $event)
 {
     $archiveName = (string) Uuid::uuid1();
     $projectRootDir = realpath($this->projectRootDir);
     $archivePath = realpath($this->archiveDir) . '/' . $archiveName . '.zip';
     $archive = $this->openArchive($archivePath);
     foreach ($this->exportedCollection as $exportable) {
         if ($exportable instanceof ExportableInterface) {
             $exportPath = $projectRootDir . '/' . $exportable->getExportDestination();
             if (file_exists($exportPath)) {
                 $exportFile = new \SplFileObject($exportPath);
                 $archive->addFile($exportPath, $exportFile->getFilename());
             } else {
                 $this->logger->error(sprintf('Could not find export at "%s"', $exportPath));
                 // TODO Emit ErrorEvent to be handled later on for more robustness
                 continue;
             }
         }
     }
     $this->closeArchive($archive, $archivePath);
     if ($event instanceof JobAwareEventInterface) {
         if (!file_exists($archivePath)) {
             throw new UnavailableArchiveException(sprintf('Could not find archive at "%s"', $archivePath), UnavailableArchiveException::DEFAULT_CODE);
         }
         /** @var \WeavingTheWeb\Bundle\ApiBundle\Entity\Job $job */
         $job = $event->getJob();
         $archiveFile = new \SplFileObject($archivePath);
         $filename = str_replace('.zip', '', $archiveFile->getFilename());
         $router = $this->router;
         $getArchiveUrl = $this->router->generate('weaving_the_web_api_get_archive', ['filename' => $filename], $router::ABSOLUTE_PATH);
         $job->setOutput($getArchiveUrl);
     }
     $this->exportedCollection = [];
 }
开发者ID:WeavingTheWeb,项目名称:devobs,代码行数:40,代码来源:ExportSubscriber.php

示例4: getImage

 /**
  * @param string $filename
  * @param string $name
  * @return string
  */
 private function getImage($filename, $name)
 {
     $path = $this->getContainer()->getParameter("upload_dir") . "images/post/";
     $file = new \SplFileObject($path . $name, "w");
     $file->fwrite(file_get_contents($filename));
     return $file->getFilename();
 }
开发者ID:Eraac,项目名称:TP-Blog,代码行数:12,代码来源:ImageCommand.php

示例5: __construct

 public function __construct($filepath)
 {
     $file = new \SplFileObject($filepath);
     $this->path = $file->getFilename();
     while (!$file->eof()) {
         $this->content .= $file->fgets();
     }
 }
开发者ID:kaiwa,项目名称:clsi-client,代码行数:8,代码来源:TextFileResource.php

示例6: buildRequestParams

 /**
  * @param \SplFileObject $file
  * @param array $options
  *
  * @return array
  */
 private function buildRequestParams(\SplFileObject $file, array $options)
 {
     $multipart = [['name' => 'batch', 'contents' => $file, 'filename' => $file->getFilename()]];
     foreach ($options as $key => $value) {
         $multipart[] = ['name' => $key, 'contents' => $value];
     }
     return compact('multipart');
 }
开发者ID:vindi,项目名称:vindi-php,代码行数:14,代码来源:ImportBatch.php

示例7: getModelClassHelperData

 public function getModelClassHelperData()
 {
     $paths = $this->modelsPath;
     $paths = array_unique($paths);
     $return = [];
     foreach ($paths as $path) {
         $namespace = str_replace(["@", "/"], ["\\", "\\"], $path);
         $realPath = Yii::getAlias($path);
         $files = \app\core\helpers\FileHelper::findFiles($realPath, ['only' => ['*.php'], 'except' => ['*Search.php', '*Query.php', '*Form.php']]);
         foreach ($files as $file) {
             $file = new \SplFileObject($file);
             $className = substr($file->getFilename(), 0, strlen($file->getFilename()) - (strlen($file->getExtension()) + 1));
             $class = new \ReflectionClass($namespace . '\\' . $className);
             $return[ltrim($namespace, '\\')][$class->getShortName() . "|" . Inflector::camel2id($class->getShortName())] = $class->getName();
         }
     }
     return $return;
 }
开发者ID:oyoy8629,项目名称:yii-core,代码行数:18,代码来源:Generator.php

示例8: countLines

 /**
  * {@inheritdoc}
  */
 public function countLines(\SplFileObject $file)
 {
     // Refresh file size
     clearstatcache($file->getFilename());
     $previous = $file->key();
     $file->seek($file->getSize());
     $count = $file->key();
     $file->seek($previous);
     return $count;
 }
开发者ID:Babacooll,项目名称:TextFile,代码行数:13,代码来源:SimpleWalker.php

示例9: getRelativePath

 /**
  * Returns the relative path of a file or a symlink in a seamless way (relatively to the project root dir)
  *
  * @param $filePath
  * @return string
  */
 public function getRelativePath($filePath)
 {
     if (!file_exists($filePath)) {
         $this->raiseFileNotExistException($filePath);
     }
     $parentDirName = basename(dirname($filePath));
     $parentDir = dirname(dirname($filePath));
     $fileObject = new \SplFileObject($filePath);
     $filename = $fileObject->getFilename();
     $relativeGrandParentDir = strtr(realpath($parentDir), [realpath($this->projectRootDir) . '/' => '', realpath($this->logsDir . '/../..') . '/' => '']);
     $relativePath = $relativeGrandParentDir . '/' . $parentDirName . '/' . $filename;
     $this->logger->info(sprintf('Returning "%s" as relative path for "%s"', $relativePath, $filePath));
     return $relativePath;
 }
开发者ID:WeavingTheWeb,项目名称:devobs,代码行数:20,代码来源:PathResolver.php

示例10: write

 /**
  * {@inheritdoc}
  */
 public function write(\SplFileObject $file, $text, $newLineAtEnd = false)
 {
     $originalSeek = $file->ftell();
     // Refresh file size
     clearstatcache($file->getFilename());
     if ($file->getSize() - $file->ftell() > 0) {
         $contentAfter = $file->fread($file->getSize() - $file->ftell());
     } else {
         $contentAfter = '';
     }
     $file->fseek($originalSeek);
     $file->fwrite($text . ($newLineAtEnd ? PHP_EOL : ''));
     $file->fwrite($contentAfter);
     return $file;
 }
开发者ID:Babacooll,项目名称:TextFile,代码行数:18,代码来源:PrependingWriter.php

示例11: getFolders

$stddirs[] = $path;
$stddirs = vTranslate::getFolders($path, $stddirs);
// Convert EVERYTHINGWOOOOOT
foreach ($stddirs as $sourcedir) {
    vTranslate::log("Processing: " . $sourcedir . "\n", $log);
    $targetpath = str_replace($path, $temppath, $sourcedir);
    if (!is_dir($targetpath)) {
        mkdir($targetpath);
    }
    $files = vTranslate::getFiles($sourcedir);
    foreach ($files as $f) {
        $file = new SplFileObject($sourcedir . '/' . $f);
        $targetfile = new SplFileObject($targetpath . '/' . $f, 'w');
        while (!$file->eof()) {
            $line = $file->fgets();
            if (strpos($file->getFilename(), '.ini')) {
                if (strpos($line, '_') === 0) {
                    $line = substr($line, 1);
                }
            } elseif (strpos($file->getFilename(), '.php')) {
                $line = str_replace("JText::_('_", "JText::_('", $line);
            }
            $targetfile->fwrite($line);
        }
    }
}
// et voilà
vTranslate::log("All done." . "\n\n", $log);
class vTranslate
{
    public function getFolders($path, $list = array(), $other = false)
开发者ID:Ibrahim1,项目名称:aec,代码行数:31,代码来源:vmanipulate.php

示例12: getFileName

 /**
  * Returns the current file name
  *
  * @return string
  */
 public function getFileName()
 {
     return $this->file->getFilename();
 }
开发者ID:stedop,项目名称:playground-framework,代码行数:9,代码来源:BasicFileHandler.php

示例13: getFilename

 /**
  * {@inheritdoc}
  */
 public function getFilename()
 {
     return $this->file ? $this->file->getFilename() : null;
 }
开发者ID:ynloultratech,项目名称:framework,代码行数:7,代码来源:ReaderTrait.php

示例14: _getFile

 private function _getFile($download = false)
 {
     if (!$this->authed && !$this->config->readonly) {
         echo json_encode(array('status' => false, 'message' => 'not authenticated'));
         exit;
     }
     if (!$this->requestDir || !is_file($this->requestDir)) {
         header('Status: 404 Not Found');
         header('HTTP/1.0 404 Not Found');
         exit;
     }
     $file = new SplFileObject($this->requestDir);
     // not really sure if this range shit works. stole it from an old script i wrote
     if (isset($_SERVER['HTTP_RANGE'])) {
         list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2);
         if ($size_unit == 'bytes') {
             list($range, $extra_ranges) = explode(',', $range_orig, 2);
         } else {
             $range = '';
         }
         if ($range) {
             list($seek_start, $seek_end) = explode('-', $range, 2);
         }
         $seek_end = empty($seek_end) ? $size - 1 : min(abs(intval($seek_end)), $size - 1);
         $seek_start = empty($seek_start) || $seek_end < abs(intval($seek_start)) ? 0 : max(abs(intval($seek_start)), 0);
         if ($seek_start > 0 || $seek_end < $size - 1) {
             header('HTTP/1.1 206 Partial Content');
         } else {
             header('HTTP/1.1 200 OK');
         }
         header('Accept-Ranges: bytes');
         header('Content-Range: bytes ' . $seek_start . '-' . $seek_end . '/' . $size);
         $contentLength = $seek_end - $seek_start + 1;
     } else {
         header('HTTP/1.1 200 OK');
         header('Accept-Ranges: bytes');
         $contentLength = $file->getSize();
     }
     header('Pragma: public');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Date: ' . date('r'));
     header('Last-Modified: ' . date('r', $file->getMTime()));
     header('Content-Length: ' . $contentLength);
     header('Content-Transfer-Encoding: binary');
     if ($download) {
         header('Content-Disposition: attachment; filename="' . $file->getFilename() . '"');
         header('Content-Type: application/force-download');
     } else {
         header('Content-Type: ' . mime_content_type($file->getPathname()));
     }
     // i wrote this freading a really long time ago but it seems to be more robust than SPL. someone correct me if im wrong
     $fp = fopen($file->getPathname(), 'rb');
     fseek($fp, $seek_start);
     while (!feof($fp)) {
         set_time_limit(0);
         print fread($fp, 1024 * 8);
         flush();
         ob_flush();
     }
     fclose($fp);
     exit;
 }
开发者ID:pinoaffe,项目名称:cheryl,代码行数:62,代码来源:Cheryl.php

示例15: 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


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