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


PHP SplFileObject::isReadable方法代码示例

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


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

示例1: testInit

 /**
  * @return      void
  */
 public function testInit()
 {
     $filePath = __DIR__ . '/example_read.txt';
     $fileObject = new FileReader($filePath, 'r', true);
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->isReadable());
     $fileObject = new \SplFileObject($filePath, 'r');
     $this->assertEquals($filePath, $fileObject->getPathname());
     $this->assertTrue($fileObject->isReadable());
 }
开发者ID:naucon,项目名称:file,代码行数:13,代码来源:FileReaderTest.php

示例2: in

 /**
  * Add input argument
  *
  * @param string $filePath
  *            Input file path
  *
  * @return Identify
  * @throws \InvalidArgumentException
  */
 public function in($filePath)
 {
     if (!file_exists($filePath)) {
         $message = 'The input file path (' . $filePath . ') is invalid or the file could not be located.';
         throw new \InvalidArgumentException($message);
     }
     $file = new \SplFileObject($filePath);
     if ($file->isReadable()) {
         $this->inputFile = '"' . $file->getPathname() . '"';
     }
     $this->getQuery()->dirty();
     return $this;
 }
开发者ID:localgod,项目名称:karla,代码行数:22,代码来源:Identify.php

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

示例4: validateChecksum

 /**
  * Validate the current installation directory against an existing checksum file
  * This reports any changes to your installation directory - added, removed or changed files
  *
  * @author	Steve Kenow <skenow@impresscms.org>
  *
  */
 public static function validateChecksum()
 {
     $validationFile = new SplFileObject($checkfile);
     if ($validationFile->isReadable()) {
         $currentHash = $currentPerms = array();
         $cache_dir = preg_replace('#[\\|/]#', DIRECTORY_SEPARATOR, ICMS_CACHE_PATH);
         $templates_dir = preg_replace('#[\\|/]#', DIRECTORY_SEPARATOR, ICMS_COMPILE_PATH);
         foreach (new RecursiveIteratorIterator($dir) as $name => $item) {
             $itemPath = $item->getPath();
             $itemFilename = $item->getBasename();
             $itemPerms = $item->getPerms();
             /* exclude cache and templates_c directories */
             if ($itemPath != $cache_dir && $itemPath != $templates_dir) {
                 $fileHash = sha1_file($name);
                 $currentHash[$name] = $fileHash;
                 $currentPerms[$name] = $itemPerms;
             }
         }
         echo _CORE_CHECKSUM_CHECKFILE . $checkfile . '<br />';
         $validHash = $validPerms = array();
         while (!$validationFile->eof()) {
             list($filename, $checksum, $filePermissions) = $validationFile->fgetcsv(';');
             $validHash[$filename] = $checksum;
             $validPerms[$filename] = $filePermissions;
         }
         $hashVariations = array_diff_assoc($validHash, $currentHash);
         // changed or removed files
         $addedFiles = array_diff_key($currentHash, $validHash);
         $missingFiles = array_diff_key($validHash, $currentHash);
         $permVariations = array_diff_assoc($validPerms, $currentPerms);
         // changed permissions or removed files
         echo '<br /><strong>' . count($hashVariations) . _CORE_CHECKSUM_ALTERED_REMOVED . '</strong><br />';
         foreach ($hashVariations as $file => $check) {
             echo $file . '<br />';
         }
         echo '<br /><strong>' . count($addedFiles) . _CORE_CHECKSUM_FILES_ADDED . '</strong><br />';
         foreach ($addedFiles as $file => $hash) {
             echo $file . '<br />';
         }
         echo '<br /><strong>' . count($missingFiles) . _CORE_CHECKSUM_FILES_REMOVED . '</strong><br />';
         foreach ($missingFiles as $file => $hash) {
             echo $file . '<br />';
         }
         echo '<br /><strong>' . count($permVariations) . _CORE_CHECKSUM_PERMISSIONS_ALTERED . '</strong><br />';
         foreach ($permVariations as $file => $perms) {
             echo $file . '<br />';
         }
     } else {
         echo _CORE_CHECKSUM_CHECKFILE_UNREADABLE;
     }
     unset($validationFile);
     unset($item);
     unset($dir);
 }
开发者ID:nao-pon,项目名称:impresscms,代码行数:61,代码来源:Filesystem.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: getTags

 /**
  * Obtain test case tags
  *
  * @return Array
  */
 function getTags()
 {
     if (empty($this->_tagsMap)) {
         $testCaseFileObj = new SplFileObject($this->_testCaseFile);
         $line = "";
         $inTags = false;
         if ($testCaseFileObj->isReadable()) {
             while ($testCaseFileObj->valid() && $line != "#--- End tags\n") {
                 $line = $testCaseFileObj->fgets();
                 if ($inTags && $line == "#--- End tags\n") {
                     $inTags = false;
                 }
                 if ($inTags) {
                     $this->_tagsMap[] = trim(str_replace("#", "", $line));
                 }
                 if (!$inTags && $line == "#--- Start tags\n") {
                     $inTags = true;
                 }
             }
         }
     }
     return $this->_tagsMap;
 }
开发者ID:benm-stm,项目名称:FireOpal,代码行数:28,代码来源:TestCase.class.php


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