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


PHP SplFileObject::isFile方法代码示例

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


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

示例1: setFile

 /**
  * @param $file
  * @return $this
  */
 public function setFile($file)
 {
     $this->file = new \SplFileObject($file, "r");
     if (!$this->file->isFile()) {
         throw new \Exception(sprintf("Invalid file for parsing %s", $file));
     }
     return $this;
 }
开发者ID:tvart,项目名称:libs,代码行数:12,代码来源:CsvParser.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: _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

示例4: array

<?php

$regex = '/^([a-zA-Z0-9\\/]?)+[a-zA-Z0-9_]+\\.{1}[a-z]+$/';
/// test for file name validity (not complete)
$delimieter = array('|', "\t");
if (preg_match($regex, $argv[1]) === 1 && preg_match($regex, $argv[2]) === 1) {
    try {
        $values = array();
        $s1 = new SplFileObject($argv[1], 'r');
        $s1->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
        if ($s1->isFile() && $s1->isReadable()) {
            $s1->seek(1);
            while ($row = $s1->fgetcsv($delimieter[0])) {
                $data = array($row[7], $row[8]);
                if (!in_array($data, $values)) {
                    $values[] = $data;
                }
            }
            unset($row);
            usort($values, function ($a, $b) {
                return $a[0] > $b[0];
            });
            try {
                $s2 = new SplFileObject($argv[2], 'w');
                $s2->fputcsv(array('id', 'code'), $delimieter[1]);
                foreach ($values as $data) {
                    $s2->fputcsv($data, "\t");
                }
            } catch (RuntimeException $e) {
                echo $e->getMessage();
                exit($e->severity);
开发者ID:malaimo2900,项目名称:geography_mapping,代码行数:31,代码来源:createStateList.php

示例5: importDunes

 /**
  * Reads an dune import file containing dune data and returns a site object.
  *
  * @param string $filePath       The file path location for the
  * @param bool   $errorOnBadData If true and exception will be thrown due to a line of bad data. If false the
  *                               line is skipped silently.
  *
  * @return Site A Site object populated with dunes.
  * @throws InvalidOperationException If database credentials have not been set (required for dune creation)
  * @throws MyInvalidArgumentException If the import path is invalid.
  */
 public final function importDunes($filePath, $errorOnBadData = TRUE)
 {
     if (is_null(self::$databaseCredentials)) {
         throw new InvalidOperationException('Database credentials must be set at the class level to allow this action to take place.');
     }
     Dune::setDatabaseCredentials(self::$databaseCredentials);
     $fileHandle = new SplFileObject($filePath);
     if (!$fileHandle->isFile() && !$fileHandle->isReadable() && $fileHandle->getExtension() != 'txt') {
         throw new MyInvalidArgumentException('The specified import file path does not point to a valid readable text (.txt) file.');
     }
     while (!$fileHandle->eof()) {
         $duneData = $fileHandle->fgetcsv(' ');
         if ($duneData[0] == NULL || substr($duneData[0], 0, 1) == '%') {
             continue;
             // Skip the line
         }
         if (count($duneData) != 6) {
             if ($errorOnBadData) {
                 $line = $fileHandle->key() + 1;
                 throw new MyInvalidArgumentException('Import failed. Line ' . $line . ' does not contain sufficient data or is
                     improperly formatted.');
             } else {
                 continue;
             }
         }
         try {
             $dune = new Dune(new LatLng($duneData[3], $duneData[2]), $this->siteName, $duneData[5], $duneData[4]);
             $this->dunes[] = $dune;
         } catch (Exception $e) {
             if ($errorOnBadData) {
                 $line = $fileHandle->key() + 1;
                 throw new MyInvalidArgumentException('Import failed. Line ' . $line . ' contains invalid data.', $e);
             } else {
                 continue;
             }
         }
     }
 }
开发者ID:WARPed1701D,项目名称:twlProject,代码行数:49,代码来源:Site.php

示例6: SplFileObject

<?php

$s = new SplFileObject(__FILE__);
var_dump($s->isFile());
var_dump($s->isDir());
var_dump($s->isLink());
开发者ID:badlamer,项目名称:hhvm,代码行数:6,代码来源:fileobject_checktype_basic.php


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