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


PHP SplFileInfo::getPerms方法代码示例

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


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

示例1: __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

示例2: _parse

 /**
  * @param mixed $variable
  *
  * @return false|null
  */
 protected function _parse(&$variable)
 {
     /** @noinspection PhpUsageOfSilenceOperatorInspection */
     if (is_object($variable) || is_array($variable) || (string) $variable !== $variable || strlen($variable) > 2048 || preg_match('[[:?<>"*|]]', $variable) || !@is_readable($variable)) {
         return false;
     }
     try {
         $fileInfo = new \SplFileInfo($variable);
         $flags = array();
         $perms = $fileInfo->getPerms();
         if (($perms & 0xc000) === 0xc000) {
             $type = 'File socket';
             $flags[] = 's';
         } elseif (($perms & 0xa000) === 0xa000) {
             $type = 'File symlink';
             $flags[] = 'l';
         } elseif (($perms & 0x8000) === 0x8000) {
             $type = 'File';
             $flags[] = '-';
         } elseif (($perms & 0x6000) === 0x6000) {
             $type = 'Block special file';
             $flags[] = 'b';
         } elseif (($perms & 0x4000) === 0x4000) {
             $type = 'Directory';
             $flags[] = 'd';
         } elseif (($perms & 0x2000) === 0x2000) {
             $type = 'Character special file';
             $flags[] = 'c';
         } elseif (($perms & 0x1000) === 0x1000) {
             $type = 'FIFO pipe file';
             $flags[] = 'p';
         } else {
             $type = 'Unknown file';
             $flags[] = 'u';
         }
         // owner
         $flags[] = $perms & 0x100 ? 'r' : '-';
         $flags[] = $perms & 0x80 ? 'w' : '-';
         $flags[] = $perms & 0x40 ? $perms & 0x800 ? 's' : 'x' : ($perms & 0x800 ? 'S' : '-');
         // group
         $flags[] = $perms & 0x20 ? 'r' : '-';
         $flags[] = $perms & 0x10 ? 'w' : '-';
         $flags[] = $perms & 0x8 ? $perms & 0x400 ? 's' : 'x' : ($perms & 0x400 ? 'S' : '-');
         // world
         $flags[] = $perms & 0x4 ? 'r' : '-';
         $flags[] = $perms & 0x2 ? 'w' : '-';
         $flags[] = $perms & 0x1 ? $perms & 0x200 ? 't' : 'x' : ($perms & 0x200 ? 'T' : '-');
         $this->type = $type;
         $this->size = sprintf('%.2fK', $fileInfo->getSize() / 1024);
         $this->value = implode($flags);
     } catch (\Exception $e) {
         return false;
     }
 }
开发者ID:voku,项目名称:kint,代码行数:59,代码来源:Kint_Parsers_FsPath.php

示例3: validateSetting

 /**
  * Validate directory
  *
  * Checks to see if file is directory and if permissions match expected
  *
  * @param SplFileInfo $file     File to check
  * @param array       $badFiles current array of bad files to report
  *
  * @return array
  * @access public
  */
 public function validateSetting(SplFileInfo $file, array $badFiles)
 {
     if ($file->isDir()) {
         $path = substr_replace($file->__toString(), '', 0, strlen(Mage::getBaseDir()) + 1);
         if (Mage::helper('bronto_verify/permissionchecker')->accept($path)) {
             $octalPerms = substr(sprintf('%o', $file->getPerms()), -$this->_permLen);
             if ($octalPerms != $this->_permission) {
                 $badFiles[$path]['directory permission'] = $octalPerms;
             }
         }
     }
     return parent::validateSetting($file, $badFiles);
 }
开发者ID:bevello,项目名称:bevello,代码行数:24,代码来源:Directory.php

示例4: toArray

 /**
  * @return array
  */
 public function toArray()
 {
     $rows = [];
     $currentDir = getcwd() . DIRECTORY_SEPARATOR;
     /* @var $reflection ReflectionFile  */
     foreach ($this->getIterator() as $reflection) {
         $row = [];
         $file = new \SplFileInfo($reflection->getName());
         $row = array("Files" => str_replace($currentDir, "", $file->getPathName()), "Owner" => $file->getOwner(), "Group" => $file->getGroup(), "Permissions" => $file->getPerms(), "Created" => date("d.m.Y h:m:s", $file->getCTime()), "Modified" => date("d.m.Y h:m:s", $file->getMTime()));
         $rows[] = $row;
     }
     return $rows;
 }
开发者ID:slavomirkuzma,项目名称:itc-bundle,代码行数:16,代码来源:FileCollection.php

示例5: testReportXmlFileNotReadable

 public function testReportXmlFileNotReadable()
 {
     $validator = new LintValidation(new LibXmlErrorFormatter());
     $filename = dirname(dirname(__DIR__)) . '/functional/_testdata/fourtytwo.xml';
     $file = new \SplFileInfo($filename);
     $fileMod = $file->getPerms();
     try {
         chmod($filename, 0333);
         $mock = $this->getMock(FileReport::class, ['reportProblem'], [$file]);
         $mock->expects($this->once())->method('reportProblem')->with('file not readable: ' . $file->getRealPath());
         /** @var FileReport $mock */
         $return = $validator->validateFile($mock);
         $this->assertFalse($return);
     } finally {
         chmod($filename, $fileMod);
     }
 }
开发者ID:sclable,项目名称:xml-lint,代码行数:17,代码来源:LintValidationTest.php

示例6: SplFileInfo

<?php

//file
touch('SplFileInfo_getPerms_basic.txt');
chmod('SplFileInfo_getPerms_basic.txt', 0557);
$fileInfo = new SplFileInfo('SplFileInfo_getPerms_basic.txt');
var_dump($fileInfo->getPerms() == 0100557);
error_reporting(0);
unlink('SplFileInfo_getPerms_basic.txt');
开发者ID:badlamer,项目名称:hhvm,代码行数:9,代码来源:SplFileInfo_getPerms_basic.php

示例7: SplFileInfo

                     }
                 }
             }
         } else {
             //TODO not sure if this is needed!
             if ($key != 'files' && $key != 'dirs') {
                 $f2s = $key . '/' . $val;
                 if (substr($f2s, -3) == 'php') {
                     $output .= 'File: ' . $f2s . PHP_EOL;
                 }
             }
         }
     }
 } else {
     $info = new SplFileInfo($o2s);
     $perms = substr(sprintf('%o', $info->getPerms()), -4);
     $owner = $info->getOwner();
     $group = $info->getGroup();
     $type = $info->getType();
     $size = $info->getSize();
     $scanner = new Scanner($o2s, $eol, $htmlMode, $scannerOptions);
     $scanner->scanFile("all", $patternData, $stringData);
     if (count($scanner->found)) {
         foreach ($scanner->found as $l) {
             $found .= $l;
         }
     } else {
         $found = '';
     }
     //make human readable size
     $size = $scanner->size_readable($size);
开发者ID:xinomilo,项目名称:Ghost-in-the-shell,代码行数:31,代码来源:gis.php

示例8: testDecoratedMethods

 public function testDecoratedMethods()
 {
     $decorated = $this->getMockBuilder('hanneskod\\classtools\\Tests\\MockSplFileInfo')->setConstructorArgs([''])->getMock();
     $decorated->expects($this->once())->method('getRelativePath');
     $decorated->expects($this->once())->method('getRelativePathname');
     $decorated->expects($this->once())->method('getContents');
     $decorated->expects($this->once())->method('getATime');
     $decorated->expects($this->once())->method('getBasename');
     $decorated->expects($this->once())->method('getCTime');
     $decorated->expects($this->once())->method('getExtension');
     $decorated->expects($this->once())->method('getFileInfo');
     $decorated->expects($this->once())->method('getFilename');
     $decorated->expects($this->once())->method('getGroup');
     $decorated->expects($this->once())->method('getInode');
     $decorated->expects($this->once())->method('getLinkTarget');
     $decorated->expects($this->once())->method('getMTime');
     $decorated->expects($this->once())->method('getOwner');
     $decorated->expects($this->once())->method('getPath');
     $decorated->expects($this->once())->method('getPathInfo');
     $decorated->expects($this->once())->method('getPathname');
     $decorated->expects($this->once())->method('getPerms');
     $decorated->expects($this->once())->method('getRealPath');
     $decorated->expects($this->once())->method('getSize');
     $decorated->expects($this->once())->method('getType');
     $decorated->expects($this->once())->method('isDir');
     $decorated->expects($this->once())->method('isExecutable');
     $decorated->expects($this->once())->method('isFile');
     $decorated->expects($this->once())->method('isLink');
     $decorated->expects($this->once())->method('isReadable');
     $decorated->expects($this->once())->method('isWritable');
     $decorated->expects($this->once())->method('openFile');
     $decorated->expects($this->once())->method('setFileClass');
     $decorated->expects($this->once())->method('setInfoClass');
     $decorated->expects($this->once())->method('__toString')->will($this->returnValue(''));
     $fileInfo = new SplFileInfo($decorated);
     $fileInfo->getRelativePath();
     $fileInfo->getRelativePathname();
     $fileInfo->getContents();
     $fileInfo->getATime();
     $fileInfo->getBasename();
     $fileInfo->getCTime();
     $fileInfo->getExtension();
     $fileInfo->getFileInfo();
     $fileInfo->getFilename();
     $fileInfo->getGroup();
     $fileInfo->getInode();
     $fileInfo->getLinkTarget();
     $fileInfo->getMTime();
     $fileInfo->getOwner();
     $fileInfo->getPath();
     $fileInfo->getPathInfo();
     $fileInfo->getPathname();
     $fileInfo->getPerms();
     $fileInfo->getRealPath();
     $fileInfo->getSize();
     $fileInfo->getType();
     $fileInfo->isDir();
     $fileInfo->isExecutable();
     $fileInfo->isFile();
     $fileInfo->isLink();
     $fileInfo->isReadable();
     $fileInfo->isWritable();
     $fileInfo->openFile();
     $fileInfo->setFileClass();
     $fileInfo->setInfoClass();
     (string) $fileInfo;
 }
开发者ID:hanneskod,项目名称:classtools,代码行数:67,代码来源:SplFileInfoTest.php

示例9: evaluate


//.........这里部分代码省略.........
                 $this->fmt->startRow();
                 $this->fmt->text('resourceProp', ucwords(str_replace('_', ' ', $key)));
                 $this->fmt->colDiv($max - static::strLen($key));
                 $this->fmt->sep(':');
                 $this->fmt->colDiv();
                 $this->evaluate($value);
                 $this->fmt->endRow();
             }
             $this->fmt->endGroup();
             return;
             // string
         // string
         case 'string':
             $length = static::strLen($subject);
             $encoding = static::$env['mbStr'] ? mb_detect_encoding($subject) : false;
             $info = $encoding && $encoding !== 'ASCII' ? $length . '; ' . $encoding : $length;
             if ($specialStr) {
                 $this->fmt->sep('"');
                 $this->fmt->text(array('string', 'special'), $subject, "string({$info})");
                 $this->fmt->sep('"');
                 return;
             }
             $this->fmt->text('string', $subject, "string({$info})");
             // advanced checks only if there are 3 characteres or more
             if (static::$config['showStringMatches'] && $length > 2 && trim($subject) !== '') {
                 $isNumeric = is_numeric($subject);
                 // very simple check to determine if the string could match a file path
                 // @note: this part of the code is very expensive
                 $isFile = $length < 2048 && max(array_map('strlen', explode('/', str_replace('\\', '/', $subject)))) < 128 && !preg_match('/[^\\w\\.\\-\\/\\\\:]|\\..*\\.|\\.$|:(?!(?<=^[a-zA-Z]:)[\\/\\\\])/', $subject);
                 if ($isFile) {
                     try {
                         $file = new \SplFileInfo($subject);
                         $flags = array();
                         $perms = $file->getPerms();
                         if (($perms & 0xc000) === 0xc000) {
                             // socket
                             $flags[] = 's';
                         } elseif (($perms & 0xa000) === 0xa000) {
                             // symlink
                             $flags[] = 'l';
                         } elseif (($perms & 0x8000) === 0x8000) {
                             // regular
                             $flags[] = '-';
                         } elseif (($perms & 0x6000) === 0x6000) {
                             // block special
                             $flags[] = 'b';
                         } elseif (($perms & 0x4000) === 0x4000) {
                             // directory
                             $flags[] = 'd';
                         } elseif (($perms & 0x2000) === 0x2000) {
                             // character special
                             $flags[] = 'c';
                         } elseif (($perms & 0x1000) === 0x1000) {
                             // FIFO pipe
                             $flags[] = 'p';
                         } else {
                             // unknown
                             $flags[] = 'u';
                         }
                         // owner
                         $flags[] = $perms & 0x100 ? 'r' : '-';
                         $flags[] = $perms & 0x80 ? 'w' : '-';
                         $flags[] = $perms & 0x40 ? $perms & 0x800 ? 's' : 'x' : ($perms & 0x800 ? 'S' : '-');
                         // group
                         $flags[] = $perms & 0x20 ? 'r' : '-';
                         $flags[] = $perms & 0x10 ? 'w' : '-';
开发者ID:jackzard,项目名称:JackFramework,代码行数:67,代码来源:ref.php

示例10: fixFilePermission

 /**
  * @param \SplFileInfo $fileInfo
  */
 private function fixFilePermission(\SplFileInfo $fileInfo)
 {
     try {
         $permission = substr(sprintf('%o', $fileInfo->getPerms()), -4);
     } catch (\Exception $e) {
         // cannot get permissions...
         return;
     }
     $newPermission = $permission;
     // set owner-bit to writable
     $newPermission[1] = '6';
     // set group-bit to writable
     $newPermission[2] = '6';
     $newPermission = octdec($newPermission);
     chmod($fileInfo->getPathname(), $newPermission);
     clearstatcache(false, $fileInfo->getPathname());
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:20,代码来源:FileSystem.php

示例11: SplFileInfo

<?php

include __DIR__ . '/../../../test/sample_dir/fix_mtimes.inc';
$info = new SplFileInfo(__DIR__ . '/../../sample_dir');
if (!$info->isFile()) {
    echo $info->getRealPath();
}
$info = new SplFileInfo(__DIR__ . '/../../sample_dir/file');
var_dump($info->getbaseName());
var_dump($info->getbaseName('.cpp'));
$info->getCTime();
$info->getGroup();
$info->getInode();
$info->getMTime();
$info->getOwner();
$info->getPerms();
$info->getSize();
$info->getType();
$info->isDir();
$info->isFile();
$info->isLink();
$info->isReadable();
$info->isWritable();
开发者ID:badlamer,项目名称:hhvm,代码行数:23,代码来源:1795.php

示例12: createFileResult

 /**
  * @param SplFileInfo $file
  *
  * @return array
  */
 private function createFileResult(SplFileInfo $file)
 {
     $fileResult = array('path' => $this->replaceWindowsPath($this->getRelativePath($file->getRealPath(), ABSPATH)), 'pathEncoded' => false, 'isLink' => false, 'exists' => false, 'isDirectory' => false, 'owner' => 0, 'group' => 0, 'permissions' => 0);
     if (!seems_utf8($fileResult['path'])) {
         $fileResult['path'] = $this->pathEncode($fileResult['path']);
         $fileResult['pathEncoded'] = true;
     }
     try {
         $fileResult['link'] = $file->isLink();
         // need to be first
         $fileResult['size'] = $file->getSize();
         $fileResult['isDirectory'] = $file->isDir();
         $fileResult['owner'] = $file->getOwner();
         $fileResult['group'] = $file->getGroup();
         $fileResult['permissions'] = $file->getPerms();
         $fileResult['exists'] = true;
         if ($file->isLink()) {
             $fileResult['linkTarget'] = $file->getLinkTarget();
         }
     } catch (RuntimeException $e) {
     }
     return $fileResult;
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:28,代码来源:ListFiles.php

示例13: testPermission

 /**
  * @depends     testExist
  * @return      void
  */
 public function testPermission()
 {
     $filePath = __DIR__ . '/example.txt';
     $fileObject = new File($filePath);
     $this->assertGreaterThan(0, $fileObject->getPermission());
     $this->assertEquals(4, strlen($fileObject->getPermission()));
     $fileObject = new \SplFileInfo($filePath);
     $this->assertGreaterThan(0, $fileObject->getPerms());
     $this->assertEquals(4, strlen(substr(decoct($fileObject->getPerms()), 2)));
     // deviation
 }
开发者ID:naucon,项目名称:file,代码行数:15,代码来源:FileTest.php

示例14: getFileDetailsRawStatistic

 protected function getFileDetailsRawStatistic(\SplFileInfo $info, $fileGiven)
 {
     return ['File is Dir' => $info->isDir(), 'File is Executable' => $info->isExecutable(), 'File is File' => $info->isFile(), 'File is Link' => $info->isLink(), 'File is Readable' => $info->isReadable(), 'File is Writable' => $info->isWritable(), 'File Permissions' => $this->explainPerms($info->getPerms()), 'Size' => $info->getSize(), 'Sha1' => sha1_file($fileGiven), 'Timestamp Accessed' => $this->getFileTimes($info->getATime()), 'Timestamp Changed' => $this->getFileTimes($info->getCTime()), 'Timestamp Modified' => $this->getFileTimes($info->getMTime())];
 }
开发者ID:danielgp,项目名称:common-lib,代码行数:4,代码来源:CommonBasic.php


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