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


PHP SplFileInfo::isReadable方法代码示例

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


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

示例1: loadCachedFile

 protected function loadCachedFile()
 {
     if (!$this->cacheFile->isReadable()) {
         return null;
     }
     if ($this->cacheFile->getMTime() < $this->dataFile->getMTime()) {
         return null;
     }
     $jsonString = file_get_contents($this->cacheFile->getPathname());
     if (false === $jsonString) {
         throw new InvalidArgumentException("Can not read file content from '{$this->cacheFile->getPathname()}'!");
     }
     return CiteCollection::loadFromJson($jsonString);
 }
开发者ID:Weltraumschaf,项目名称:weltraumschaf.de,代码行数:14,代码来源:CiteProvider.php

示例2: importSingleMovie

 public function importSingleMovie(\SplFileInfo $source)
 {
     if (!$source->isReadable()) {
         return $this->output->writelnError(sprintf("File %s not readable", $source->getFilename()));
     }
     $this->output->writelnInfo(sprintf("Importing %s ...", $source->getRealPath()));
     $file = $source->openFile();
     /** @var Movies $movie */
     $movie = $this->getMovie($file->fread($file->getSize()), $file->getBasename('.html'));
     if (!$movie) {
         return $this->output->writelnError(sprintf("Not found dmm id", $source->getFilename()));
     }
     $this->currentDmmId = $movie->banngo;
     if (Movies::findFirstById($movie->id)) {
         return $this->output->writelnWarning(sprintf("Movie %s already exists, insert skipped", $movie->banngo));
     }
     /** @var Mysql $db */
     $db = $this->getDI()->get('dbMaster');
     $db->begin();
     if (false === $movie->save()) {
         $db->rollback();
         return $this->output->writelnError(sprintf("Movie saving failed by %s", implode(',', $movie->getMessages())));
     }
     $db->commit();
     $this->output->writelnSuccess(sprintf("Movie %s saving success as %s, detail: %s", $movie->banngo, $movie->id, ''));
 }
开发者ID:AlloVince,项目名称:yinxing,代码行数:26,代码来源:ImportDmmTask.php

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

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

示例5: createDirectory

/**
 * Recursively create a directory if allowed.
 *
 * @param string $path     The path to the directory which will be created.
 * @param int $permissions The Unix permissions to set on the directory. Ignored
 *                         on Windows machines.
 *
 * @return void
 *
 * @throws \LogicException           if the directory already exists.
 * @throws \UnexpectedValueException if the first existing parent directory in
 *                                   the $path argument is not readable or
 *                                   writable by the user running PHP.
 * @throws \UnexpectedValueException when a recursive call to mkdir() with the
 *                                   given $path and $permissions arguments
 *                                   fails.
 */
function createDirectory($path, $permissions = 0755)
{
    if (is_dir($path)) {
        throw new \LogicException('De map "' . $path . '" bestaat al.', 2);
    }
    // Find the first parent directory and check its permissions.
    $permission = false;
    $parentPath = $path;
    do {
        $parentPath = explode(DIRECTORY_SEPARATOR, trim($parentPath, DIRECTORY_SEPARATOR));
        $parentPathCount = count($parentPath);
        unset($parentPath[--$parentPathCount]);
        $parentPath = implode(DIRECTORY_SEPARATOR, $parentPath);
        // Don't prepend the path with a directory separator on Windows.
        // The drive letter, for example: "C:\", is enough.
        if (PHP_OS !== 'Windows') {
            $parentPath = DIRECTORY_SEPARATOR . $parentPath;
        }
        if (file_exists($parentPath)) {
            $fileInfo = new \SplFileInfo($parentPath);
            if ($fileInfo->isReadable() && $fileInfo->isWritable()) {
                $permission = true;
                break;
            }
        }
    } while ($parentPathCount > 1);
    if ($permission) {
        if (!mkdir($path, $permissions, true)) {
            throw new \UnexpectedValueException('De map "' . $path . '" kon niet aangemaakt worden.', 8);
        }
    } else {
        throw new \UnexpectedValueException('De eerstvolgende bestaande map die boven "' . $path . '" ligt ' . 'is niet lees- of schrijfbaar.', 4);
    }
}
开发者ID:BitmanNL,项目名称:traffictower-cms,代码行数:51,代码来源:createDirectory.php

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

示例7: __construct

 /**
  * Constructs the file cache driver
  *
  * [!!] Note: This method cannot be invoked externally.
  *
  * The file cache driver must be instantiated using the `Cache::instance()` method.
  *
  * @param   array  $config  Config for file cache driver
  *
  * @throws  Cache_Exception
  */
 protected function __construct(array $config)
 {
     // Setup parent
     parent::__construct($config);
     $directory = Arr::get($this->_config, 'cache_dir', Kohana::$cache_dir);
     try {
         $this->_cache_dir = new SplFileInfo($directory);
     } catch (ErrorException $e) {
         $this->_cache_dir = $this->_make_directory($directory, 0777, TRUE);
     } catch (UnexpectedValueException $e) {
         $this->_cache_dir = $this->_make_directory($directory, 0777, TRUE);
     }
     // If the defined directory is a file, get outta here
     if ($this->_cache_dir->isFile()) {
         throw new Cache_Exception('Unable to create cache directory as a file already exists : :resource', array(':resource' => $this->_cache_dir->getRealPath()));
     }
     // Check the read status of the directory
     if (!$this->_cache_dir->isReadable()) {
         throw new Cache_Exception('Unable to read from the cache directory :resource', array(':resource' => $this->_cache_dir->getRealPath()));
     }
     // Check the write status of the directory
     if (!$this->_cache_dir->isWritable()) {
         throw new Cache_Exception('Unable to write to the cache directory :resource', array(':resource' => $this->_cache_dir->getRealPath()));
     }
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:36,代码来源:file.php

示例8: __construct

 public function __construct(\SplFileInfo $file, $priority = 0)
 {
     if (!$file->isReadable()) {
         throw new \RuntimeException(sprintf('Pipeline source not readable: "%s"', $file->getPathname()));
     }
     $this->file = $file;
     $this->priority = (int) $priority;
 }
开发者ID:koolkode,项目名称:http-komponent,代码行数:8,代码来源:FileSource.php

示例9: readFile

 /**
  * @see \Bolt\Database\Migration\Input\InputFileInterface::readFile()
  */
 public function readFile()
 {
     $filename = (string) $this->file;
     if ($this->file->isReadable()) {
         try {
             $data = $this->parser->parse(file_get_contents($filename) . "\n");
             $this->import->setData($data);
             return true;
         } catch (ParseException $e) {
             $this->import->setError(true)->setErrorMessage("File '{$filename}' has invalid YAML!");
             return false;
         }
     } else {
         $this->import->setError(true)->setErrorMessage("File '{$filename}' not readable!");
         return false;
     }
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:20,代码来源:YamlFile.php

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

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

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

 /**
  * @param string $filename
  * @param string $mimeType
  * @return Blob
  * @throws NuxeoClientException
  */
 public static function fromFile($filename, $mimeType)
 {
     $fileInfo = new \SplFileInfo($filename);
     if ($fileInfo->isReadable()) {
         return new Blob($fileInfo->getFilename(), $fileInfo, $mimeType);
     } else {
         throw NuxeoClientException::fromPrevious(new NoSuchFileException($filename));
     }
 }
开发者ID:nuxeo,项目名称:nuxeo-automation-php-client,代码行数:15,代码来源:Blob.php

示例14: downloadAction

 /**
  * @param Request $request
  *
  * @return BinaryFileResponse
  *
  * @throws HttpException
  */
 public function downloadAction(Request $request)
 {
     $document = new \SplFileInfo($this->resources . '/' . $request->get('fileName'));
     if (!$document->isReadable()) {
         throw new HttpException(404);
     }
     $response = new BinaryFileResponse($document);
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $document->getFilename());
     return $response;
 }
开发者ID:WinterborneStickland,项目名称:parish-council-website,代码行数:17,代码来源:FinanceController.php

示例15: importXmlFile

 public function importXmlFile(\SplFileInfo $source)
 {
     if (!$source->isReadable()) {
         return $this->output->writelnError(sprintf("File %s not readable", $source->getFilename()));
     }
     $this->output->writelnInfo(sprintf("Importing %s ...", $source->getRealPath()));
     $file = $source->openFile();
     $xml = simplexml_load_string($file->fread($file->getSize()));
     return $this->saveDmmList($xml);
 }
开发者ID:AlloVince,项目名称:yinxing,代码行数:10,代码来源:ImportDmmXmlTask.php


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