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


PHP SplFileInfo::isFile方法代码示例

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


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

示例1: validateContent

 /**
  * {@inheritDoc}
  */
 public function validateContent($content)
 {
     if (is_string($content)) {
         $content = new \SplFileInfo($content);
     }
     return $content instanceof \SplFileInfo && $content->isFile();
 }
开发者ID:jmcclell,项目名称:OryzoneMediaStorage,代码行数:10,代码来源:FileProvider.php

示例2: accept

    /**
     * UnsortedEpisodesFilter::accept()
     *
     * @return
     */
    public function accept()
    {
        $file = new SplFileInfo( $this->getInnerIterator()->current() );

        if ( !$file->isFile() )
        {
            echo "Not a file<br />";
            return false;
        }


        if ( !preg_match( '/\.(mkv|avi)$/ ', $file->getBasename() ) )
        {
            echo "Not a video<br />";
            return false;
        }

        if ( $file->getSize() < ( 25 * 1024 * 1024 ) )
        {
            echo "Too small<br />";
            return false;
        }

        $subtitleFileNames = array( $file->getBasename() . '.srt', $file->getBasename() . '.ass' );
        foreach ( $subtitleFileNames as $subtitleFileName )
            if ( file_exists( $subtitleFileName ) )
                return false;
    }
开发者ID:rangulicon,项目名称:mkvmanager,代码行数:33,代码来源:unsorted_episodes.php

示例3: make_writable

 /**
  * This function will make directory writable.
  *
  * @param   string  path
  * @return  void
  * @throw   Kohana_Exception
  */
 public static function make_writable($path, $chmod = NULL)
 {
     try {
         $dir = new SplFileInfo($path);
         if ($dir->isFile()) {
             throw new Kohana_Exception('Could not make :path writable directory because it is regular file', array(':path' => Debug::path($path)));
         } elseif ($dir->isLink()) {
             throw new Kohana_Exception('Could not make :path writable directory because it is link', array(':path' => Debug::path($path)));
         } elseif (!$dir->isDir()) {
             // Try create directory
             Ku_Dir::make($path, $chmod);
             clearstatcache(TRUE, $path);
         }
         if (!$dir->isWritable()) {
             // Try make directory writable
             chmod($dir->getRealPath(), $chmod === NULL ? Ku_Dir::$default_dir_chmod : $chmod);
             clearstatcache(TRUE, $path);
             // Check result
             if (!$dir->isWritable()) {
                 throw new Exception('Make dir writable failed', 0);
             }
         }
     } catch (Kohana_Exception $e) {
         // Rethrow exception
         throw $e;
     } catch (Exception $e) {
         throw new Kohana_Exception('Could not make :path directory writable', array(':path' => Debug::path($path)));
     }
 }
开发者ID:greor,项目名称:satin-spb,代码行数:36,代码来源:dir.php

示例4: findResource

 public function findResource($path)
 {
     $path = trim($path, '/\\');
     if ($path == '') {
         $info = new \SplFileInfo($this->pathBase);
         if ($info->isFile()) {
             return new FilesystemFile('', $info, $this);
         }
         return new FilesystemDirectory('', $info, $this);
     }
     $target = @realpath($this->pathBase . DIRECTORY_SEPARATOR . $path);
     if ($target === false || !file_exists($target) || 0 !== strpos($target, $this->pathBase)) {
         throw new \OutOfBoundsException(sprintf('Target resource not found: "%s"', $path));
     }
     $info = new \SplFileInfo($target);
     if ($info->isFile()) {
         $resource = new FilesystemFile($path, $info, $this);
         $sql = 'SELECT * FROM "file_locks" WHERE "resource" = :resource AND "expires" > :time';
         $stmt = $this->lockStore->prepare($sql);
         $stmt->bindValue('resource', trim($resource->getPath(), '/'));
         $stmt->bindValue('time', time());
         $stmt->execute();
         if (false !== ($row = $stmt->fetch(\PDO::FETCH_ASSOC))) {
             $resource->setLockInfo($this->unserializeLock($row));
         }
         return $resource;
     }
     return new FilesystemDirectory($path, $info, $this);
 }
开发者ID:koolkode,项目名称:webdav,代码行数:29,代码来源:FilesystemStorage.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fileInfo = new \SplFileInfo($this->getContainer()->getParameter('kernel.root_dir') . '/../web/sitemap.xml');
     if ($fileInfo->isFile() && $fileInfo->isReadable()) {
         $output->write('Reading sitemap.xml...');
         $file = $fileInfo->openFile();
         $xml = '';
         while (!$file->eof()) {
             $xml .= $file->fgets();
         }
         $output->writeln(' done.');
         $output->write('Updating sitemap.xml...');
         $sitemap = new \SimpleXMLIterator($xml);
         $sitemap->rewind();
         $lastmodDate = new \DateTime();
         $lastmodDate->sub(new \DateInterval('P1D'));
         $lastmodDateFormatted = $lastmodDate->format('Y-m-d');
         while ($sitemap->valid()) {
             $sitemap->current()->lastmod = $lastmodDateFormatted;
             $sitemap->next();
         }
         $file = $file->openFile('w');
         $file->fwrite($sitemap->asXML());
         $output->writeln(' done.');
     } else {
         $output->writeln('Error: Cannot open file web/sitemap.xml');
     }
 }
开发者ID:Quiss,项目名称:Evrika,代码行数:28,代码来源:UpdateSitemapCommand.php

示例6: __construct

 /**
  * Stores the file object.
  *
  * @param \SplFileInfo $file The file object
  *
  * @throws \InvalidArgumentException If $file is not a file
  */
 public function __construct(\SplFileInfo $file)
 {
     if (!$file->isFile()) {
         throw new \InvalidArgumentException(sprintf('%s is not a file.', $file));
     }
     $this->file = $file;
 }
开发者ID:bytehead,项目名称:core-bundle,代码行数:14,代码来源:HtaccessAnalyzer.php

示例7: validate

 /**
  * Main check method
  *
  * @param string $pathToFile
  * @throws \RuntimeException if file not found
  * @return bool
  */
 public function validate($pathToFile)
 {
     $this->clearErrors();
     $path = new \SplFileInfo($pathToFile);
     if (!$path->isFile() || !$path->isReadable()) {
         throw new \RuntimeException(sprintf('File "%s" not found', $pathToFile));
     }
     $file = $path->openFile('r');
     $currentLineNumber = 1;
     while (!$file->eof()) {
         $line = $file->fgets();
         if ($line == '' && $file->eof()) {
             break;
         }
         // Validate line structure
         $this->validateEOL($currentLineNumber, $line);
         $nodes = array_filter(preg_split('/\\s+/', $line));
         // Validate label
         $label = array_shift($nodes);
         $this->validateLabel($currentLineNumber, $label);
         // Validate features format
         $this->validateFeatures($currentLineNumber, $nodes);
         // Increate the line number
         $currentLineNumber++;
     }
     return $this->isValid();
 }
开发者ID:sjoerdmaessen,项目名称:machinelearning,代码行数:34,代码来源:SVMLight.php

示例8: testGetFilename

 /**
  * @covers Versionable\Prospect\Response\File::__construct
  * @covers Versionable\Prospect\Response\File::getFilename
  */
 public function testGetFilename()
 {
     $filename = $this->object->getFilename();
     $this->assertNotNull($filename);
     $test = new \SplFileInfo($filename);
     $this->assertFalse($test->isFile());
 }
开发者ID:versionable,项目名称:prospect,代码行数:11,代码来源:FileTest.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configHelper = $this->getHelper('configuration');
     /* @var $configHelper GlobalConfigurationHelper */
     $questionHelper = $this->getHelper('question');
     /* @var $questionHelper QuestionHelper */
     $sshConfig = new \SplFileInfo($configHelper->getConfiguration()->getSshDirectory() . '/config');
     if (!$sshConfig->isFile()) {
         throw new NotAFileException($sshConfig);
     }
     if (!$sshConfig->isReadable()) {
         throw new UnreadableFileException($sshConfig);
     }
     if (!$sshConfig->isWritable()) {
         throw new UnwritableFileException($sshConfig);
     }
     $sshConfigLines = file($sshConfig->getPathname());
     $repoName = $input->getArgument('repository');
     $repositoryConfig = $configHelper->getConfiguration()->getRepositoryConfiguration($repoName);
     if (!$questionHelper->ask($input, $output, new ConfirmationQuestion(sprintf('Are you sure you want to remove the ssh key for "%s"? This action is irreversible.', $repoName)))) {
         return 1;
     }
     $sshKeyFile = $repositoryConfig->getIdentityFile();
     $this->unlinkFile($output, $sshKeyFile);
     $this->unlinkFile($output, $sshKeyFile . '.pub');
     if (Util::removeSshAliasLines($sshConfigLines, $repositoryConfig)) {
         $output->writeln(sprintf('Removed section <info>Host %s</info> from <info>%s</info>', $repositoryConfig->getSshAlias(), $sshConfig->getPathname()), OutputInterface::VERBOSITY_VERBOSE);
     }
     $output->writeln(sprintf('Removed repository <info>%s</info>', $repoName));
     $configHelper->getConfiguration()->removeRepositoryConfiguration($repoName);
     FsUtil::file_put_contents($sshConfig->getPathname(), implode('', $sshConfigLines));
     $configHelper->getConfiguration()->write();
     return 0;
 }
开发者ID:vierbergenlars,项目名称:clic,代码行数:34,代码来源:RemoveCommand.php

示例10: scan_view

 /**
  * Scans an individual view file, adding it's version number (if found) to the
  * $this->views array.
  *
  * @param SplFileInfo $file
  */
 protected function scan_view(SplFileInfo $file)
 {
     if (!$file->isFile() || !$file->isReadable()) {
         return;
     }
     $version = $this->get_template_version($file->getPathname());
     $this->originals[$this->short_name($file->getPathname())] = $version;
 }
开发者ID:partisan-collective,项目名称:partisan,代码行数:14,代码来源:Template_Checker.php

示例11: calculate

 /**
  * Returns file checksum
  *
  * @param string $file
  * @return string
  */
 public function calculate($file)
 {
     $file = new \SplFileInfo($file);
     if (!$file->isFile() && !$file->isReadable()) {
         throw new \InvalidArgumentException('Invalid argument supplied for checksum calculation, only existing files are allowed');
     }
     return sprintf('%s:%s', $file->getMTime(), $file->getSize());
 }
开发者ID:ecomdev,项目名称:compiler,代码行数:14,代码来源:Basic.php

示例12: setFilePath

 /**
  * @param string $filePath
  * @throws InvalidArgumentException
  */
 public function setFilePath($filePath)
 {
     $this->fileInfo = new \SplFileInfo($filePath);
     if (!$this->fileInfo->isFile()) {
         throw new InvalidArgumentException(sprintf('File "%s" does not exists.', $filePath));
     } elseif (!$this->fileInfo->isReadable()) {
         throw new InvalidArgumentException(sprintf('File "%s" is not readable.', $this->fileInfo->getRealPath()));
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:CsvFileReader.php

示例13: __construct

 public function __construct(SplFileInfo $fileInfo)
 {
     $this->perms = $fileInfo->getPerms();
     $this->size = $fileInfo->getSize();
     $this->is_dir = $fileInfo->isDir();
     $this->is_file = $fileInfo->isFile();
     $this->is_link = $fileInfo->isLink();
     if (($this->perms & 0xc000) === 0xc000) {
         $this->typename = 'File socket';
         $this->typeflag = 's';
     } elseif ($this->is_file) {
         if ($this->is_link) {
             $this->typename = 'File symlink';
             $this->typeflag = 'l';
         } else {
             $this->typename = 'File';
             $this->typeflag = '-';
         }
     } elseif (($this->perms & 0x6000) === 0x6000) {
         $this->typename = 'Block special file';
         $this->typeflag = 'b';
     } elseif ($this->is_dir) {
         if ($this->is_link) {
             $this->typename = 'Directory symlink';
             $this->typeflag = 'l';
         } else {
             $this->typename = 'Directory';
             $this->typeflag = 'd';
         }
     } elseif (($this->perms & 0x2000) === 0x2000) {
         $this->typename = 'Character special file';
         $this->typeflag = 'c';
     } elseif (($this->perms & 0x1000) === 0x1000) {
         $this->typename = 'FIFO pipe file';
         $this->typeflag = 'p';
     }
     parent::__construct('FsPath');
     $this->path = $fileInfo->getPathname();
     $this->realpath = realpath($this->path);
     if ($this->is_link && method_exists($fileInfo, 'getLinktarget')) {
         $this->linktarget = $fileInfo->getLinktarget();
     }
     $flags = array($this->typeflag);
     // User
     $flags[] = $this->perms & 0x100 ? 'r' : '-';
     $flags[] = $this->perms & 0x80 ? 'w' : '-';
     $flags[] = $this->perms & 0x40 ? $this->perms & 0x800 ? 's' : 'x' : ($this->perms & 0x800 ? 'S' : '-');
     // Group
     $flags[] = $this->perms & 0x20 ? 'r' : '-';
     $flags[] = $this->perms & 0x10 ? 'w' : '-';
     $flags[] = $this->perms & 0x8 ? $this->perms & 0x400 ? 's' : 'x' : ($this->perms & 0x400 ? 'S' : '-');
     // Other
     $flags[] = $this->perms & 0x4 ? 'r' : '-';
     $flags[] = $this->perms & 0x2 ? 'w' : '-';
     $flags[] = $this->perms & 0x1 ? $this->perms & 0x200 ? 't' : 'x' : ($this->perms & 0x200 ? 'T' : '-');
     $this->contents = implode($flags);
 }
开发者ID:jnvsor,项目名称:kint,代码行数:57,代码来源:FsPath.php

示例14: getEntryWithPermalinkId

 public function getEntryWithPermalinkId($permalink_id)
 {
     $this->validatePermalinkId($permalink_id);
     $file = new \SplFileInfo($this->datadir . '/' . $permalink_id . '.' . $this->file_extension);
     if ($file->isFile()) {
         return new Entry($file, $this);
     }
     return null;
 }
开发者ID:Windy619,项目名称:Bloghoven,代码行数:9,代码来源:BlosxomDirContentProvider.php

示例15: createBatch

 public function createBatch($name)
 {
     $dir = sprintf('%s/%s', $this->dir, $this->checkName($name));
     $fileInfo = new \SplFileInfo($dir);
     if ($fileInfo->isDir() || $fileInfo->isFile()) {
         throw new InvalidArgumentException(sprintf('Batch name exists: "%s"', $name));
     }
     mkdir($dir, 0777);
     return $this->batchFactory->getInstance($dir);
 }
开发者ID:kompakt,项目名称:mediameister,代码行数:10,代码来源:DropDir.php


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