mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
MOBI debug: Fix reading of first and last text record numbers from MOBI 6 headers
This commit is contained in:
parent
75b30cf99a
commit
bb4ae8102e
@ -306,10 +306,15 @@ class MOBIHeader(object): # {{{
|
||||
self.extra_data_flags = 0
|
||||
if self.has_extra_data_flags:
|
||||
self.unknown4 = self.raw[184:192]
|
||||
self.fdst_idx, self.fdst_count = struct.unpack_from(b'>LL',
|
||||
self.raw, 192)
|
||||
if self.fdst_count <= 1:
|
||||
self.fdst_idx = NULL_INDEX
|
||||
if self.file_version < 8:
|
||||
self.first_text_record, self.last_text_record = \
|
||||
struct.unpack_from(b'>HH', self.raw, 192)
|
||||
self.fdst_count = struct.unpack_from(b'>L', self.raw, 196)
|
||||
else:
|
||||
self.fdst_idx, self.fdst_count = struct.unpack_from(b'>LL',
|
||||
self.raw, 192)
|
||||
if self.fdst_count <= 1:
|
||||
self.fdst_idx = NULL_INDEX
|
||||
(self.fcis_number, self.fcis_count, self.flis_number,
|
||||
self.flis_count) = struct.unpack(b'>IIII',
|
||||
self.raw[200:216])
|
||||
@ -409,7 +414,11 @@ class MOBIHeader(object): # {{{
|
||||
a('DRM Flags: %r'%self.drm_flags)
|
||||
if self.has_extra_data_flags:
|
||||
a('Unknown4: %r'%self.unknown4)
|
||||
r('FDST Index', 'fdst_idx')
|
||||
if hasattr(self, 'first_text_record'):
|
||||
a('First text record: %d'%self.first_text_record)
|
||||
a('Last text record: %d'%self.last_text_record)
|
||||
else:
|
||||
r('FDST Index', 'fdst_idx')
|
||||
a('FDST Count: %d'% self.fdst_count)
|
||||
r('FCIS number', 'fcis_number')
|
||||
a('FCIS count: %d'% self.fcis_count)
|
||||
|
Loading…
x
Reference in New Issue
Block a user