1 | <?php |
||
10 | class NativeFileInfo implements IFileInfo { |
||
11 | const MODE_FILE = 0100000; |
||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $path; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $name; |
||
22 | |||
23 | /** |
||
24 | * @var \Icewind\SMB\NativeShare |
||
25 | */ |
||
26 | protected $share; |
||
27 | |||
28 | /** |
||
29 | * @var array|null |
||
30 | */ |
||
31 | protected $statCache; |
||
32 | |||
33 | /** |
||
34 | * @var int |
||
35 | */ |
||
36 | protected $modeCache; |
||
37 | |||
38 | /** |
||
39 | * @param \Icewind\SMB\NativeShare $share |
||
40 | * @param string $path |
||
41 | * @param string $name |
||
42 | * @param array $stat |
||
43 | */ |
||
44 | 206 | public function __construct($share, $path, $name, $stat = null) { |
|
50 | |||
51 | /** |
||
52 | * @return string |
||
53 | */ |
||
54 | public function getPath() { |
||
55 | return $this->path; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | public function getName() { |
||
62 | return $this->name; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return array |
||
67 | */ |
||
68 | 26 | protected function stat() { |
|
69 | 26 | if (is_null($this->statCache)) { |
|
70 | $this->statCache = $this->share->getStat($this->getPath()); |
||
71 | } |
||
72 | 26 | return $this->statCache; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return int |
||
77 | */ |
||
78 | 26 | public function getSize() { |
|
82 | |||
83 | /** |
||
84 | * @return int |
||
85 | */ |
||
86 | public function getMTime() { |
||
87 | $stat = $this->stat(); |
||
88 | return $stat['mtime']; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * @return bool |
||
93 | */ |
||
94 | public function isDirectory() { |
||
95 | $stat = $this->stat(); |
||
96 | return !($stat['mode'] & self::MODE_FILE); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * @return int |
||
101 | */ |
||
102 | 26 | protected function getMode() { |
|
110 | |||
111 | /** |
||
112 | * @return bool |
||
113 | */ |
||
114 | 16 | public function isReadOnly() { |
|
118 | |||
119 | /** |
||
120 | * @return bool |
||
121 | */ |
||
122 | 26 | public function isHidden() { |
|
126 | |||
127 | /** |
||
128 | * @return bool |
||
129 | */ |
||
130 | 16 | public function isSystem() { |
|
134 | |||
135 | /** |
||
136 | * @return bool |
||
137 | */ |
||
138 | 16 | public function isArchived() { |
|
142 | } |
||
143 |