1 | <?php |
||
10 | class Entry |
||
11 | { |
||
12 | /** |
||
13 | * Is the content cache enabled? |
||
14 | * |
||
15 | * @var bool |
||
16 | */ |
||
17 | protected static $contentCacheEnabled = false; |
||
18 | |||
19 | /** |
||
20 | * Is the content cache enabled? |
||
21 | * |
||
22 | * @return bool |
||
23 | */ |
||
24 | 491 | public static function getContentCacheEnabled() |
|
28 | |||
29 | /** |
||
30 | * Enable/disable the content cache. |
||
31 | * |
||
32 | * @param bool $enabled |
||
33 | */ |
||
34 | public static function setContentCacheEnabled($enabled) |
||
38 | |||
39 | /** |
||
40 | * Entry type: directory. |
||
41 | * |
||
42 | * @var int |
||
43 | */ |
||
44 | const TYPE_DIRECTORY = 0x1; |
||
45 | |||
46 | /** |
||
47 | * Entry type: normal file. |
||
48 | * |
||
49 | * @var int |
||
50 | */ |
||
51 | const TYPE_FILE = 0x2; |
||
52 | |||
53 | /** |
||
54 | * Entry type: special file. |
||
55 | * |
||
56 | * @var int |
||
57 | */ |
||
58 | const TYPE_SPECIAL_FILE = 0x4; |
||
59 | |||
60 | /** |
||
61 | * Entry type: meta data. |
||
62 | * |
||
63 | * @var int |
||
64 | */ |
||
65 | const TYPE_METADATA = 0x8; |
||
66 | |||
67 | /** |
||
68 | * The parent CHM file. |
||
69 | * |
||
70 | * @var CHM |
||
71 | */ |
||
72 | protected $chm; |
||
73 | |||
74 | /** |
||
75 | * The path of this entry. |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | protected $path; |
||
80 | |||
81 | /** |
||
82 | * The index of the content section that contains the data of this entry. |
||
83 | * |
||
84 | * @var int |
||
85 | */ |
||
86 | protected $contentSectionIndex; |
||
87 | |||
88 | /** |
||
89 | * The offset of the entry data from the beginning of the content section this entry is in, after the section has been decompressed (if appropriate). |
||
90 | * |
||
91 | * @var int |
||
92 | */ |
||
93 | protected $offset; |
||
94 | |||
95 | /** |
||
96 | * The length of the entry data after decompression (if appropriate). |
||
97 | * |
||
98 | * @var int |
||
99 | */ |
||
100 | protected $length; |
||
101 | |||
102 | /** |
||
103 | * The type of this entry (one of the static::TYPE_... constants). |
||
104 | * |
||
105 | * @var int |
||
106 | */ |
||
107 | protected $type; |
||
108 | |||
109 | /** |
||
110 | * The previously read contents of this entry. |
||
111 | * |
||
112 | * @var string|null |
||
113 | */ |
||
114 | protected $cachedContents; |
||
115 | |||
116 | /** |
||
117 | * Initializes the instance. |
||
118 | * |
||
119 | * @param CHM $chm The parent CHM file. |
||
120 | */ |
||
121 | 4 | public function __construct(CHM $chm) |
|
144 | |||
145 | /** |
||
146 | * Get the path of this entry. |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | 7 | public function getPath() |
|
154 | |||
155 | /** |
||
156 | * Get the index of the content section that contains the data of this entry. |
||
157 | * |
||
158 | * @return int |
||
159 | */ |
||
160 | 4 | public function getContentSectionIndex() |
|
164 | |||
165 | /** |
||
166 | * Get the offset from the beginning of the content section this entry is in, after the section has been decompressed (if appropriate). |
||
167 | * |
||
168 | * @return int |
||
169 | */ |
||
170 | 4 | public function getOffset() |
|
174 | |||
175 | /** |
||
176 | * Get the length of the entry data after decompression (if appropriate). |
||
177 | * |
||
178 | * @return int |
||
179 | */ |
||
180 | 4 | public function getLength() |
|
184 | |||
185 | /** |
||
186 | * Is this a directory entry? |
||
187 | * |
||
188 | * @return bool |
||
189 | */ |
||
190 | public function isDirectory() |
||
194 | |||
195 | /** |
||
196 | * Is this a normal file entry? |
||
197 | * |
||
198 | * @return bool |
||
199 | */ |
||
200 | 1 | public function isFile() |
|
204 | |||
205 | /** |
||
206 | * Is this a special file entry? |
||
207 | * |
||
208 | * @return bool |
||
209 | */ |
||
210 | public function isSpecialFile() |
||
214 | |||
215 | /** |
||
216 | * Is this a meta-data entry? |
||
217 | * |
||
218 | * @return bool |
||
219 | */ |
||
220 | public function isMetaData() |
||
224 | |||
225 | /** |
||
226 | * Get the type of this entry (one of the static::TYPE_... constants). |
||
227 | * |
||
228 | * @return int |
||
229 | */ |
||
230 | 3 | public function getType() |
|
234 | |||
235 | /** |
||
236 | * Get the contents of this entry. |
||
237 | * |
||
238 | * @throws Exception Throws an Exception in case of errors. |
||
239 | * |
||
240 | * @return string |
||
241 | */ |
||
242 | 491 | public function getContents() |
|
258 | } |
||
259 |