|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class Kint_Objects_SplFileInfo extends KintObject |
|
4
|
|
|
{ |
|
5
|
|
|
public function parse( & $variable ) |
|
6
|
|
|
{ |
|
7
|
|
|
if ( !KINT_PHP53 || !is_object( $variable ) || !$variable instanceof SplFileInfo ) return false; |
|
8
|
|
|
|
|
9
|
|
|
$this->name = 'SplFileInfo'; |
|
10
|
|
|
$this->value = $variable->getBasename(); |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
$flags = array(); |
|
14
|
|
|
$perms = $variable->getPerms(); |
|
15
|
|
|
|
|
16
|
|
View Code Duplication |
if ( ( $perms & 0xC000 ) === 0xC000 ) { |
|
17
|
|
|
$type = 'File socket'; |
|
18
|
|
|
$flags[] = 's'; |
|
19
|
|
|
} elseif ( ( $perms & 0xA000 ) === 0xA000 ) { |
|
20
|
|
|
$type = 'File symlink'; |
|
21
|
|
|
$flags[] = 'l'; |
|
22
|
|
|
} elseif ( ( $perms & 0x8000 ) === 0x8000 ) { |
|
23
|
|
|
$type = 'File'; |
|
24
|
|
|
$flags[] = '-'; |
|
25
|
|
|
} elseif ( ( $perms & 0x6000 ) === 0x6000 ) { |
|
26
|
|
|
$type = 'Block special file'; |
|
27
|
|
|
$flags[] = 'b'; |
|
28
|
|
|
} elseif ( ( $perms & 0x4000 ) === 0x4000 ) { |
|
29
|
|
|
$type = 'Directory'; |
|
30
|
|
|
$flags[] = 'd'; |
|
31
|
|
|
} elseif ( ( $perms & 0x2000 ) === 0x2000 ) { |
|
32
|
|
|
$type = 'Character special file'; |
|
33
|
|
|
$flags[] = 'c'; |
|
34
|
|
|
} elseif ( ( $perms & 0x1000 ) === 0x1000 ) { |
|
35
|
|
|
$type = 'FIFO pipe file'; |
|
36
|
|
|
$flags[] = 'p'; |
|
37
|
|
|
} else { |
|
38
|
|
|
$type = 'Unknown file'; |
|
39
|
|
|
$flags[] = 'u'; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
// owner |
|
43
|
|
|
$flags[] = ( ( $perms & 0x0100 ) ? 'r' : '-' ); |
|
44
|
|
|
$flags[] = ( ( $perms & 0x0080 ) ? 'w' : '-' ); |
|
45
|
|
|
$flags[] = ( ( $perms & 0x0040 ) ? ( ( $perms & 0x0800 ) ? 's' : 'x' ) : ( ( $perms & 0x0800 ) ? 'S' : '-' ) ); |
|
46
|
|
|
|
|
47
|
|
|
// group |
|
48
|
|
|
$flags[] = ( ( $perms & 0x0020 ) ? 'r' : '-' ); |
|
49
|
|
|
$flags[] = ( ( $perms & 0x0010 ) ? 'w' : '-' ); |
|
50
|
|
|
$flags[] = ( ( $perms & 0x0008 ) ? ( ( $perms & 0x0400 ) ? 's' : 'x' ) : ( ( $perms & 0x0400 ) ? 'S' : '-' ) ); |
|
51
|
|
|
|
|
52
|
|
|
// world |
|
53
|
|
|
$flags[] = ( ( $perms & 0x0004 ) ? 'r' : '-' ); |
|
54
|
|
|
$flags[] = ( ( $perms & 0x0002 ) ? 'w' : '-' ); |
|
55
|
|
|
$flags[] = ( ( $perms & 0x0001 ) ? ( ( $perms & 0x0200 ) ? 't' : 'x' ) : ( ( $perms & 0x0200 ) ? 'T' : '-' ) ); |
|
56
|
|
|
|
|
57
|
|
|
$size = sprintf( '%.2fK', $variable->getSize() / 1024 ); |
|
58
|
|
|
$flags = implode( $flags ); |
|
59
|
|
|
$path = $variable->getRealPath(); |
|
60
|
|
|
|
|
61
|
|
|
return array( |
|
62
|
|
|
'File information' => array( |
|
63
|
|
|
'Full path' => $path, |
|
64
|
|
|
'Type' => $type, |
|
65
|
|
|
'Size' => $size, |
|
66
|
|
|
'Flags' => $flags |
|
67
|
|
|
) |
|
68
|
|
|
); |
|
69
|
|
|
} |
|
70
|
|
|
} |