3 class Kint_Parsers_FsPath extends kintParser
5 protected function _parse( & $variable )
8 || !is_string( $variable )
9 || strlen( $variable ) > 2048
10 || preg_match( '[[:?<>"*|]]', $variable )
11 || !@is_readable( $variable ) # f@#! PHP and its random warnings
15 $fileInfo = new SplFileInfo( $variable );
17 $perms = $fileInfo->getPerms();
19 if ( ( $perms & 0xC000 ) === 0xC000 ) {
20 $type = 'File socket';
22 } elseif ( ( $perms & 0xA000 ) === 0xA000 ) {
23 $type = 'File symlink';
25 } elseif ( ( $perms & 0x8000 ) === 0x8000 ) {
28 } elseif ( ( $perms & 0x6000 ) === 0x6000 ) {
29 $type = 'Block special file';
31 } elseif ( ( $perms & 0x4000 ) === 0x4000 ) {
34 } elseif ( ( $perms & 0x2000 ) === 0x2000 ) {
35 $type = 'Character special file';
37 } elseif ( ( $perms & 0x1000 ) === 0x1000 ) {
38 $type = 'FIFO pipe file';
41 $type = 'Unknown file';
46 $flags[] = ( ( $perms & 0x0100 ) ? 'r' : '-' );
47 $flags[] = ( ( $perms & 0x0080 ) ? 'w' : '-' );
48 $flags[] = ( ( $perms & 0x0040 ) ? ( ( $perms & 0x0800 ) ? 's' : 'x' ) : ( ( $perms & 0x0800 ) ? 'S' : '-' ) );
51 $flags[] = ( ( $perms & 0x0020 ) ? 'r' : '-' );
52 $flags[] = ( ( $perms & 0x0010 ) ? 'w' : '-' );
53 $flags[] = ( ( $perms & 0x0008 ) ? ( ( $perms & 0x0400 ) ? 's' : 'x' ) : ( ( $perms & 0x0400 ) ? 'S' : '-' ) );
56 $flags[] = ( ( $perms & 0x0004 ) ? 'r' : '-' );
57 $flags[] = ( ( $perms & 0x0002 ) ? 'w' : '-' );
58 $flags[] = ( ( $perms & 0x0001 ) ? ( ( $perms & 0x0200 ) ? 't' : 'x' ) : ( ( $perms & 0x0200 ) ? 'T' : '-' ) );
61 $this->size = sprintf( '%.2fK', $fileInfo->getSize() / 1024 );
62 $this->value = implode( $flags );
64 } catch ( Exception $e ) {