summaryrefslogtreecommitdiff
path: root/python/examples/kaitai/iso9660.py
blob: dd8071a8bf992da899b77d3e544064e6ffbe8b8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild

from pkg_resources import parse_version
from .kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
import collections


if parse_version(ks_version) < parse_version('0.7'):
    raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))

class Iso9660(KaitaiStruct):
    """ISO9660 is standard filesystem used on read-only optical discs
    (mostly CD-ROM). The standard was based on earlier High Sierra
    Format (HSF), proposed for CD-ROMs in 1985, and, after several
    revisions, it was accepted as ISO9960:1998.
    
    The format emphasizes portability (thus having pretty minimal
    features and very conservative file names standards) and sequential
    access (which favors disc devices with relatively slow rotation
    speed).
    """
    SEQ_FIELDS = []
    def __init__(self, _io, _parent=None, _root=None):
        self._io = _io
        self._parent = _parent
        self._root = _root if _root else self
        self._debug = collections.defaultdict(dict)

    def _read(self):
        pass

    class VolDescPrimary(KaitaiStruct):
        """
        .. seealso::
           Source - http://wiki.osdev.org/ISO_9660#The_Primary_Volume_Descriptor
        """
        SEQ_FIELDS = ["unused1", "system_id", "volume_id", "unused2", "vol_space_size", "unused3", "vol_set_size", "vol_seq_num", "logical_block_size", "path_table_size", "lba_path_table_le", "lba_opt_path_table_le", "lba_path_table_be", "lba_opt_path_table_be", "root_dir", "vol_set_id", "publisher_id", "data_preparer_id", "application_id", "copyright_file_id", "abstract_file_id", "bibliographic_file_id", "vol_create_datetime", "vol_mod_datetime", "vol_expire_datetime", "vol_effective_datetime", "file_structure_version", "unused4", "application_area"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['unused1']['start'] = self._io.pos()
            self.unused1 = self._io.ensure_fixed_contents(b"\x00")
            self._debug['unused1']['end'] = self._io.pos()
            self._debug['system_id']['start'] = self._io.pos()
            self.system_id = (self._io.read_bytes(32)).decode(u"UTF-8")
            self._debug['system_id']['end'] = self._io.pos()
            self._debug['volume_id']['start'] = self._io.pos()
            self.volume_id = (self._io.read_bytes(32)).decode(u"UTF-8")
            self._debug['volume_id']['end'] = self._io.pos()
            self._debug['unused2']['start'] = self._io.pos()
            self.unused2 = self._io.ensure_fixed_contents(b"\x00\x00\x00\x00\x00\x00\x00\x00")
            self._debug['unused2']['end'] = self._io.pos()
            self._debug['vol_space_size']['start'] = self._io.pos()
            self.vol_space_size = self._root.U4bi(self._io, self, self._root)
            self.vol_space_size._read()
            self._debug['vol_space_size']['end'] = self._io.pos()
            self._debug['unused3']['start'] = self._io.pos()
            self.unused3 = self._io.ensure_fixed_contents(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
            self._debug['unused3']['end'] = self._io.pos()
            self._debug['vol_set_size']['start'] = self._io.pos()
            self.vol_set_size = self._root.U2bi(self._io, self, self._root)
            self.vol_set_size._read()
            self._debug['vol_set_size']['end'] = self._io.pos()
            self._debug['vol_seq_num']['start'] = self._io.pos()
            self.vol_seq_num = self._root.U2bi(self._io, self, self._root)
            self.vol_seq_num._read()
            self._debug['vol_seq_num']['end'] = self._io.pos()
            self._debug['logical_block_size']['start'] = self._io.pos()
            self.logical_block_size = self._root.U2bi(self._io, self, self._root)
            self.logical_block_size._read()
            self._debug['logical_block_size']['end'] = self._io.pos()
            self._debug['path_table_size']['start'] = self._io.pos()
            self.path_table_size = self._root.U4bi(self._io, self, self._root)
            self.path_table_size._read()
            self._debug['path_table_size']['end'] = self._io.pos()
            self._debug['lba_path_table_le']['start'] = self._io.pos()
            self.lba_path_table_le = self._io.read_u4le()
            self._debug['lba_path_table_le']['end'] = self._io.pos()
            self._debug['lba_opt_path_table_le']['start'] = self._io.pos()
            self.lba_opt_path_table_le = self._io.read_u4le()
            self._debug['lba_opt_path_table_le']['end'] = self._io.pos()
            self._debug['lba_path_table_be']['start'] = self._io.pos()
            self.lba_path_table_be = self._io.read_u4be()
            self._debug['lba_path_table_be']['end'] = self._io.pos()
            self._debug['lba_opt_path_table_be']['start'] = self._io.pos()
            self.lba_opt_path_table_be = self._io.read_u4be()
            self._debug['lba_opt_path_table_be']['end'] = self._io.pos()
            self._debug['root_dir']['start'] = self._io.pos()
            self._raw_root_dir = self._io.read_bytes(34)
            io = KaitaiStream(BytesIO(self._raw_root_dir))
            self.root_dir = self._root.DirEntry(io, self, self._root)
            self.root_dir._read()
            self._debug['root_dir']['end'] = self._io.pos()
            self._debug['vol_set_id']['start'] = self._io.pos()
            self.vol_set_id = (self._io.read_bytes(128)).decode(u"UTF-8")
            self._debug['vol_set_id']['end'] = self._io.pos()
            self._debug['publisher_id']['start'] = self._io.pos()
            self.publisher_id = (self._io.read_bytes(128)).decode(u"UTF-8")
            self._debug['publisher_id']['end'] = self._io.pos()
            self._debug['data_preparer_id']['start'] = self._io.pos()
            self.data_preparer_id = (self._io.read_bytes(128)).decode(u"UTF-8")
            self._debug['data_preparer_id']['end'] = self._io.pos()
            self._debug['application_id']['start'] = self._io.pos()
            self.application_id = (self._io.read_bytes(128)).decode(u"UTF-8")
            self._debug['application_id']['end'] = self._io.pos()
            self._debug['copyright_file_id']['start'] = self._io.pos()
            self.copyright_file_id = (self._io.read_bytes(38)).decode(u"UTF-8")
            self._debug['copyright_file_id']['end'] = self._io.pos()
            self._debug['abstract_file_id']['start'] = self._io.pos()
            self.abstract_file_id = (self._io.read_bytes(36)).decode(u"UTF-8")
            self._debug['abstract_file_id']['end'] = self._io.pos()
            self._debug['bibliographic_file_id']['start'] = self._io.pos()
            self.bibliographic_file_id = (self._io.read_bytes(37)).decode(u"UTF-8")
            self._debug['bibliographic_file_id']['end'] = self._io.pos()
            self._debug['vol_create_datetime']['start'] = self._io.pos()
            self.vol_create_datetime = self._root.DecDatetime(self._io, self, self._root)
            self.vol_create_datetime._read()
            self._debug['vol_create_datetime']['end'] = self._io.pos()
            self._debug['vol_mod_datetime']['start'] = self._io.pos()
            self.vol_mod_datetime = self._root.DecDatetime(self._io, self, self._root)
            self.vol_mod_datetime._read()
            self._debug['vol_mod_datetime']['end'] = self._io.pos()
            self._debug['vol_expire_datetime']['start'] = self._io.pos()
            self.vol_expire_datetime = self._root.DecDatetime(self._io, self, self._root)
            self.vol_expire_datetime._read()
            self._debug['vol_expire_datetime']['end'] = self._io.pos()
            self._debug['vol_effective_datetime']['start'] = self._io.pos()
            self.vol_effective_datetime = self._root.DecDatetime(self._io, self, self._root)
            self.vol_effective_datetime._read()
            self._debug['vol_effective_datetime']['end'] = self._io.pos()
            self._debug['file_structure_version']['start'] = self._io.pos()
            self.file_structure_version = self._io.read_u1()
            self._debug['file_structure_version']['end'] = self._io.pos()
            self._debug['unused4']['start'] = self._io.pos()
            self.unused4 = self._io.read_u1()
            self._debug['unused4']['end'] = self._io.pos()
            self._debug['application_area']['start'] = self._io.pos()
            self.application_area = self._io.read_bytes(512)
            self._debug['application_area']['end'] = self._io.pos()

        @property
        def path_table(self):
            if hasattr(self, '_m_path_table'):
                return self._m_path_table if hasattr(self, '_m_path_table') else None

            _pos = self._io.pos()
            self._io.seek((self.lba_path_table_le * self._root.sector_size))
            self._debug['_m_path_table']['start'] = self._io.pos()
            self._raw__m_path_table = self._io.read_bytes(self.path_table_size.le)
            io = KaitaiStream(BytesIO(self._raw__m_path_table))
            self._m_path_table = self._root.PathTableLe(io, self, self._root)
            self._m_path_table._read()
            self._debug['_m_path_table']['end'] = self._io.pos()
            self._io.seek(_pos)
            return self._m_path_table if hasattr(self, '_m_path_table') else None


    class VolDescBootRecord(KaitaiStruct):
        SEQ_FIELDS = ["boot_system_id", "boot_id"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['boot_system_id']['start'] = self._io.pos()
            self.boot_system_id = (self._io.read_bytes(32)).decode(u"UTF-8")
            self._debug['boot_system_id']['end'] = self._io.pos()
            self._debug['boot_id']['start'] = self._io.pos()
            self.boot_id = (self._io.read_bytes(32)).decode(u"UTF-8")
            self._debug['boot_id']['end'] = self._io.pos()


    class Datetime(KaitaiStruct):
        SEQ_FIELDS = ["year", "month", "day", "hour", "minute", "sec", "timezone"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['year']['start'] = self._io.pos()
            self.year = self._io.read_u1()
            self._debug['year']['end'] = self._io.pos()
            self._debug['month']['start'] = self._io.pos()
            self.month = self._io.read_u1()
            self._debug['month']['end'] = self._io.pos()
            self._debug['day']['start'] = self._io.pos()
            self.day = self._io.read_u1()
            self._debug['day']['end'] = self._io.pos()
            self._debug['hour']['start'] = self._io.pos()
            self.hour = self._io.read_u1()
            self._debug['hour']['end'] = self._io.pos()
            self._debug['minute']['start'] = self._io.pos()
            self.minute = self._io.read_u1()
            self._debug['minute']['end'] = self._io.pos()
            self._debug['sec']['start'] = self._io.pos()
            self.sec = self._io.read_u1()
            self._debug['sec']['end'] = self._io.pos()
            self._debug['timezone']['start'] = self._io.pos()
            self.timezone = self._io.read_u1()
            self._debug['timezone']['end'] = self._io.pos()


    class DirEntry(KaitaiStruct):
        SEQ_FIELDS = ["len", "body"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['len']['start'] = self._io.pos()
            self.len = self._io.read_u1()
            self._debug['len']['end'] = self._io.pos()
            if self.len > 0:
                self._debug['body']['start'] = self._io.pos()
                self._raw_body = self._io.read_bytes((self.len - 1))
                io = KaitaiStream(BytesIO(self._raw_body))
                self.body = self._root.DirEntryBody(io, self, self._root)
                self.body._read()
                self._debug['body']['end'] = self._io.pos()



    class VolDesc(KaitaiStruct):
        SEQ_FIELDS = ["type", "magic", "version", "vol_desc_boot_record", "vol_desc_primary"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['type']['start'] = self._io.pos()
            self.type = self._io.read_u1()
            self._debug['type']['end'] = self._io.pos()
            self._debug['magic']['start'] = self._io.pos()
            self.magic = self._io.ensure_fixed_contents(b"\x43\x44\x30\x30\x31")
            self._debug['magic']['end'] = self._io.pos()
            self._debug['version']['start'] = self._io.pos()
            self.version = self._io.read_u1()
            self._debug['version']['end'] = self._io.pos()
            if self.type == 0:
                self._debug['vol_desc_boot_record']['start'] = self._io.pos()
                self.vol_desc_boot_record = self._root.VolDescBootRecord(self._io, self, self._root)
                self.vol_desc_boot_record._read()
                self._debug['vol_desc_boot_record']['end'] = self._io.pos()

            if self.type == 1:
                self._debug['vol_desc_primary']['start'] = self._io.pos()
                self.vol_desc_primary = self._root.VolDescPrimary(self._io, self, self._root)
                self.vol_desc_primary._read()
                self._debug['vol_desc_primary']['end'] = self._io.pos()



    class PathTableEntryLe(KaitaiStruct):
        SEQ_FIELDS = ["len_dir_name", "len_ext_attr_rec", "lba_extent", "parent_dir_idx", "dir_name", "padding"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['len_dir_name']['start'] = self._io.pos()
            self.len_dir_name = self._io.read_u1()
            self._debug['len_dir_name']['end'] = self._io.pos()
            self._debug['len_ext_attr_rec']['start'] = self._io.pos()
            self.len_ext_attr_rec = self._io.read_u1()
            self._debug['len_ext_attr_rec']['end'] = self._io.pos()
            self._debug['lba_extent']['start'] = self._io.pos()
            self.lba_extent = self._io.read_u4le()
            self._debug['lba_extent']['end'] = self._io.pos()
            self._debug['parent_dir_idx']['start'] = self._io.pos()
            self.parent_dir_idx = self._io.read_u2le()
            self._debug['parent_dir_idx']['end'] = self._io.pos()
            self._debug['dir_name']['start'] = self._io.pos()
            self.dir_name = (self._io.read_bytes(self.len_dir_name)).decode(u"UTF-8")
            self._debug['dir_name']['end'] = self._io.pos()
            if (self.len_dir_name % 2) == 1:
                self._debug['padding']['start'] = self._io.pos()
                self.padding = self._io.read_u1()
                self._debug['padding']['end'] = self._io.pos()



    class DirEntries(KaitaiStruct):
        SEQ_FIELDS = ["entries"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['entries']['start'] = self._io.pos()
            self.entries = []
            i = 0
            while True:
                if not 'arr' in self._debug['entries']:
                    self._debug['entries']['arr'] = []
                self._debug['entries']['arr'].append({'start': self._io.pos()})
                _t_entries = self._root.DirEntry(self._io, self, self._root)
                _t_entries._read()
                _ = _t_entries
                self.entries.append(_)
                self._debug['entries']['arr'][len(self.entries) - 1]['end'] = self._io.pos()
                if _.len == 0:
                    break
                i += 1
            self._debug['entries']['end'] = self._io.pos()


    class U4bi(KaitaiStruct):
        SEQ_FIELDS = ["le", "be"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['le']['start'] = self._io.pos()
            self.le = self._io.read_u4le()
            self._debug['le']['end'] = self._io.pos()
            self._debug['be']['start'] = self._io.pos()
            self.be = self._io.read_u4be()
            self._debug['be']['end'] = self._io.pos()


    class U2bi(KaitaiStruct):
        SEQ_FIELDS = ["le", "be"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['le']['start'] = self._io.pos()
            self.le = self._io.read_u2le()
            self._debug['le']['end'] = self._io.pos()
            self._debug['be']['start'] = self._io.pos()
            self.be = self._io.read_u2be()
            self._debug['be']['end'] = self._io.pos()


    class PathTableLe(KaitaiStruct):
        """
        .. seealso::
           Source - http://wiki.osdev.org/ISO_9660#The_Path_Table
        """
        SEQ_FIELDS = ["entries"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['entries']['start'] = self._io.pos()
            self.entries = []
            i = 0
            while not self._io.is_eof():
                if not 'arr' in self._debug['entries']:
                    self._debug['entries']['arr'] = []
                self._debug['entries']['arr'].append({'start': self._io.pos()})
                _t_entries = self._root.PathTableEntryLe(self._io, self, self._root)
                _t_entries._read()
                self.entries.append(_t_entries)
                self._debug['entries']['arr'][len(self.entries) - 1]['end'] = self._io.pos()
                i += 1

            self._debug['entries']['end'] = self._io.pos()


    class DecDatetime(KaitaiStruct):
        """
        .. seealso::
           Source - http://wiki.osdev.org/ISO_9660#Date.2Ftime_format
        """
        SEQ_FIELDS = ["year", "month", "day", "hour", "minute", "sec", "sec_hundreds", "timezone"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['year']['start'] = self._io.pos()
            self.year = (self._io.read_bytes(4)).decode(u"ASCII")
            self._debug['year']['end'] = self._io.pos()
            self._debug['month']['start'] = self._io.pos()
            self.month = (self._io.read_bytes(2)).decode(u"ASCII")
            self._debug['month']['end'] = self._io.pos()
            self._debug['day']['start'] = self._io.pos()
            self.day = (self._io.read_bytes(2)).decode(u"ASCII")
            self._debug['day']['end'] = self._io.pos()
            self._debug['hour']['start'] = self._io.pos()
            self.hour = (self._io.read_bytes(2)).decode(u"ASCII")
            self._debug['hour']['end'] = self._io.pos()
            self._debug['minute']['start'] = self._io.pos()
            self.minute = (self._io.read_bytes(2)).decode(u"ASCII")
            self._debug['minute']['end'] = self._io.pos()
            self._debug['sec']['start'] = self._io.pos()
            self.sec = (self._io.read_bytes(2)).decode(u"ASCII")
            self._debug['sec']['end'] = self._io.pos()
            self._debug['sec_hundreds']['start'] = self._io.pos()
            self.sec_hundreds = (self._io.read_bytes(2)).decode(u"ASCII")
            self._debug['sec_hundreds']['end'] = self._io.pos()
            self._debug['timezone']['start'] = self._io.pos()
            self.timezone = self._io.read_u1()
            self._debug['timezone']['end'] = self._io.pos()


    class DirEntryBody(KaitaiStruct):
        SEQ_FIELDS = ["len_ext_attr_rec", "lba_extent", "size_extent", "datetime", "file_flags", "file_unit_size", "interleave_gap_size", "vol_seq_num", "len_file_name", "file_name", "padding", "rest"]
        def __init__(self, _io, _parent=None, _root=None):
            self._io = _io
            self._parent = _parent
            self._root = _root if _root else self
            self._debug = collections.defaultdict(dict)

        def _read(self):
            self._debug['len_ext_attr_rec']['start'] = self._io.pos()
            self.len_ext_attr_rec = self._io.read_u1()
            self._debug['len_ext_attr_rec']['end'] = self._io.pos()
            self._debug['lba_extent']['start'] = self._io.pos()
            self.lba_extent = self._root.U4bi(self._io, self, self._root)
            self.lba_extent._read()
            self._debug['lba_extent']['end'] = self._io.pos()
            self._debug['size_extent']['start'] = self._io.pos()
            self.size_extent = self._root.U4bi(self._io, self, self._root)
            self.size_extent._read()
            self._debug['size_extent']['end'] = self._io.pos()
            self._debug['datetime']['start'] = self._io.pos()
            self.datetime = self._root.Datetime(self._io, self, self._root)
            self.datetime._read()
            self._debug['datetime']['end'] = self._io.pos()
            self._debug['file_flags']['start'] = self._io.pos()
            self.file_flags = self._io.read_u1()
            self._debug['file_flags']['end'] = self._io.pos()
            self._debug['file_unit_size']['start'] = self._io.pos()
            self.file_unit_size = self._io.read_u1()
            self._debug['file_unit_size']['end'] = self._io.pos()
            self._debug['interleave_gap_size']['start'] = self._io.pos()
            self.interleave_gap_size = self._io.read_u1()
            self._debug['interleave_gap_size']['end'] = self._io.pos()
            self._debug['vol_seq_num']['start'] = self._io.pos()
            self.vol_seq_num = self._root.U2bi(self._io, self, self._root)
            self.vol_seq_num._read()
            self._debug['vol_seq_num']['end'] = self._io.pos()
            self._debug['len_file_name']['start'] = self._io.pos()
            self.len_file_name = self._io.read_u1()
            self._debug['len_file_name']['end'] = self._io.pos()
            self._debug['file_name']['start'] = self._io.pos()
            self.file_name = (self._io.read_bytes(self.len_file_name)).decode(u"UTF-8")
            self._debug['file_name']['end'] = self._io.pos()
            if (self.len_file_name % 2) == 0:
                self._debug['padding']['start'] = self._io.pos()
                self.padding = self._io.read_u1()
                self._debug['padding']['end'] = self._io.pos()

            self._debug['rest']['start'] = self._io.pos()
            self.rest = self._io.read_bytes_full()
            self._debug['rest']['end'] = self._io.pos()

        @property
        def extent_as_dir(self):
            if hasattr(self, '_m_extent_as_dir'):
                return self._m_extent_as_dir if hasattr(self, '_m_extent_as_dir') else None

            if (self.file_flags & 2) != 0:
                io = self._root._io
                _pos = io.pos()
                io.seek((self.lba_extent.le * self._root.sector_size))
                self._debug['_m_extent_as_dir']['start'] = io.pos()
                self._raw__m_extent_as_dir = io.read_bytes(self.size_extent.le)
                io = KaitaiStream(BytesIO(self._raw__m_extent_as_dir))
                self._m_extent_as_dir = self._root.DirEntries(io, self, self._root)
                self._m_extent_as_dir._read()
                self._debug['_m_extent_as_dir']['end'] = io.pos()
                io.seek(_pos)

            return self._m_extent_as_dir if hasattr(self, '_m_extent_as_dir') else None

        @property
        def extent_as_file(self):
            if hasattr(self, '_m_extent_as_file'):
                return self._m_extent_as_file if hasattr(self, '_m_extent_as_file') else None

            if (self.file_flags & 2) == 0:
                io = self._root._io
                _pos = io.pos()
                io.seek((self.lba_extent.le * self._root.sector_size))
                self._debug['_m_extent_as_file']['start'] = io.pos()
                self._m_extent_as_file = io.read_bytes(self.size_extent.le)
                self._debug['_m_extent_as_file']['end'] = io.pos()
                io.seek(_pos)

            return self._m_extent_as_file if hasattr(self, '_m_extent_as_file') else None


    @property
    def sector_size(self):
        if hasattr(self, '_m_sector_size'):
            return self._m_sector_size if hasattr(self, '_m_sector_size') else None

        self._m_sector_size = 2048
        return self._m_sector_size if hasattr(self, '_m_sector_size') else None

    @property
    def primary_vol_desc(self):
        if hasattr(self, '_m_primary_vol_desc'):
            return self._m_primary_vol_desc if hasattr(self, '_m_primary_vol_desc') else None

        _pos = self._io.pos()
        self._io.seek((16 * self.sector_size))
        self._debug['_m_primary_vol_desc']['start'] = self._io.pos()
        self._m_primary_vol_desc = self._root.VolDesc(self._io, self, self._root)
        self._m_primary_vol_desc._read()
        self._debug['_m_primary_vol_desc']['end'] = self._io.pos()
        self._io.seek(_pos)
        return self._m_primary_vol_desc if hasattr(self, '_m_primary_vol_desc') else None