paulgoughbooks_old
This repository has no backups
This repository's network speed is throttled to 100KB/sec
Upgrade your account to fix these warnings, or use backups.vc for automated backups
@ 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
<?php /* * The MIT License (MIT) * * Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ namespace Kint\Object\Representation; use Kint\Utils; use SplFileInfo; class SplFileInfoRepresentation extends Representation { public $perms; public $flags; public $path; public $realpath; public $linktarget; public $size; public $is_dir = false; public $is_file = false; public $is_link = false; public $owner; public $group; public $ctime; public $mtime; public $typename = 'Unknown file'; public $typeflag = '-'; public $hints = array('fspath'); public function __construct(SplFileInfo $fileInfo) { parent::__construct('SplFileInfo'); if ($fileInfo->getRealPath()) { $this->realpath = $fileInfo->getRealPath(); $this->perms = $fileInfo->getPerms(); $this->size = $fileInfo->getSize(); $this->owner = $fileInfo->getOwner(); $this->group = $fileInfo->getGroup(); $this->ctime = $fileInfo->getCTime(); $this->mtime = $fileInfo->getMTime(); } $this->path = $fileInfo->getPathname(); $this->is_dir = $fileInfo->isDir(); $this->is_file = $fileInfo->isFile(); $this->is_link = $fileInfo->isLink(); if ($this->is_link) { $this->linktarget = $fileInfo->getLinkTarget(); } switch ($this->perms & 0xF000) { case 0xC000: $this->typename = 'Socket'; $this->typeflag = 's'; break; case 0x6000: $this->typename = 'Block device'; $this->typeflag = 'b'; break; case 0x2000: $this->typename = 'Character device'; $this->typeflag = 'c'; break; case 0x1000: $this->typename = 'Named pipe'; $this->typeflag = 'p'; break; default: if ($this->is_file) { if ($this->is_link) { $this->typename = 'File symlink'; $this->typeflag = 'l'; } else { $this->typename = 'File'; $this->typeflag = '-'; } } elseif ($this->is_dir) { if ($this->is_link) { $this->typename = 'Directory symlink'; $this->typeflag = 'l'; } else { $this->typename = 'Directory'; $this->typeflag = 'd'; } } break; } $this->flags = array($this->typeflag); // User $this->flags[] = (($this->perms & 0400) ? 'r' : '-'); $this->flags[] = (($this->perms & 0200) ? 'w' : '-'); if ($this->perms & 0100) { $this->flags[] = ($this->perms & 04000) ? 's' : 'x'; } else { $this->flags[] = ($this->perms & 04000) ? 'S' : '-'; } // Group $this->flags[] = (($this->perms & 0040) ? 'r' : '-'); $this->flags[] = (($this->perms & 0020) ? 'w' : '-'); if ($this->perms & 0010) { $this->flags[] = ($this->perms & 02000) ? 's' : 'x'; } else { $this->flags[] = ($this->perms & 02000) ? 'S' : '-'; } // Other $this->flags[] = (($this->perms & 0004) ? 'r' : '-'); $this->flags[] = (($this->perms & 0002) ? 'w' : '-'); if ($this->perms & 0001) { $this->flags[] = ($this->perms & 01000) ? 's' : 'x'; } else { $this->flags[] = ($this->perms & 01000) ? 'S' : '-'; } $this->contents = \implode($this->flags).' '.$this->owner.' '.$this->group; $this->contents .= ' '.$this->getSize().' '.$this->getMTime().' '; if ($this->is_link && $this->linktarget) { $this->contents .= $this->path.' -> '.$this->linktarget; } elseif (null !== $this->realpath && \strlen($this->realpath) < \strlen($this->path)) { $this->contents .= $this->realpath; } else { $this->contents .= $this->path; } } public function getLabel() { return $this->typename.' ('.$this->getSize().')'; } public function getSize() { if ($this->size) { $size = Utils::getHumanReadableBytes($this->size); return \round($size['value'], 2).$size['unit']; } } public function getMTime() { $year = \date('Y', $this->mtime); if ($year !== \date('Y')) { return \date('M d Y', $this->mtime); } return \date('M d H:i', $this->mtime); } } |
Commits for paulgoughbooks_old/trunk/system/ThirdParty/Kint/Object/Representation/SplFileInfoRepresentation.php
Revision | Author | Commited | Message |
---|---|---|---|
2 | tporter | Tue 03 Nov, 2020 08:50:21 +0000 | Migration of Paul Goughs Books site to Codeignitor 4 |