1 | <?php |
||
10 | class Entry |
||
11 | { |
||
12 | /** |
||
13 | * Entry type: directory. |
||
14 | * |
||
15 | * @var int |
||
16 | */ |
||
17 | const TYPE_DIRECTORY = 0x1; |
||
18 | |||
19 | /** |
||
20 | * Entry type: normal file. |
||
21 | * |
||
22 | * @var int |
||
23 | */ |
||
24 | const TYPE_FILE = 0x2; |
||
25 | |||
26 | /** |
||
27 | * Entry type: special file. |
||
28 | * |
||
29 | * @var int |
||
30 | */ |
||
31 | const TYPE_SPECIAL_FILE = 0x4; |
||
32 | |||
33 | /** |
||
34 | * Entry type: meta data. |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | const TYPE_METADATA = 0x8; |
||
39 | |||
40 | /** |
||
41 | * The parent CHM file. |
||
42 | * |
||
43 | * @var CHM |
||
44 | */ |
||
45 | protected $chm; |
||
46 | |||
47 | /** |
||
48 | * The path of this entry. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $path; |
||
53 | |||
54 | /** |
||
55 | * The index of the content section that contains the data of this entry. |
||
56 | * |
||
57 | * @var int |
||
58 | */ |
||
59 | protected $contentSectionIndex; |
||
60 | |||
61 | /** |
||
62 | * 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). |
||
63 | * |
||
64 | * @var int |
||
65 | */ |
||
66 | protected $offset; |
||
67 | |||
68 | /** |
||
69 | * The length of the entry data after decompression (if appropriate). |
||
70 | * |
||
71 | * @var int |
||
72 | */ |
||
73 | protected $length; |
||
74 | |||
75 | /** |
||
76 | * The type of this entry (one of the static::TYPE_... constants). |
||
77 | * |
||
78 | * @var int |
||
79 | */ |
||
80 | protected $type; |
||
81 | |||
82 | /** |
||
83 | * Initializes the instance. |
||
84 | * |
||
85 | * @param CHM $chm The parent CHM file. |
||
86 | */ |
||
87 | 4 | public function __construct(CHM $chm) |
|
109 | |||
110 | /** |
||
111 | * Get the path of this entry. |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | 7 | public function getPath() |
|
119 | |||
120 | /** |
||
121 | * Get the index of the content section that contains the data of this entry. |
||
122 | * |
||
123 | * @return int |
||
124 | */ |
||
125 | 4 | public function getContentSectionIndex() |
|
129 | |||
130 | /** |
||
131 | * Get the offset from the beginning of the content section this entry is in, after the section has been decompressed (if appropriate). |
||
132 | * |
||
133 | * @return int |
||
134 | */ |
||
135 | 4 | public function getOffset() |
|
139 | |||
140 | /** |
||
141 | * Get the length of the entry data after decompression (if appropriate). |
||
142 | * |
||
143 | * @return int |
||
144 | */ |
||
145 | 4 | public function getLength() |
|
149 | |||
150 | /** |
||
151 | * Is this a directory entry? |
||
152 | * |
||
153 | * @return bool |
||
154 | */ |
||
155 | public function isDirectory() |
||
159 | |||
160 | /** |
||
161 | * Is this a normal file entry? |
||
162 | * |
||
163 | * @return bool |
||
164 | */ |
||
165 | 1 | public function isFile() |
|
166 | { |
||
167 | 1 | return (bool) ($this->type === static::TYPE_FILE); |
|
168 | } |
||
169 | |||
170 | /** |
||
171 | * Is this a special file entry? |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function isSpecialFile() |
||
179 | |||
180 | /** |
||
181 | * Is this a meta-data entry? |
||
182 | * |
||
183 | * @return bool |
||
184 | */ |
||
185 | public function isMetaData() |
||
189 | |||
190 | /** |
||
191 | * Get the type of this entry (one of the static::TYPE_... constants). |
||
192 | * |
||
193 | * @return int |
||
194 | */ |
||
195 | 3 | public function getType() |
|
199 | |||
200 | /** |
||
201 | * Get the contents of this entry. |
||
202 | * |
||
203 | * @throws Exception Throws an Exception in case of errors. |
||
204 | * |
||
205 | * @return string |
||
206 | */ |
||
207 | 491 | public function getContents() |
|
216 | } |
||
217 |