1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2025-12-18 13:10:17 +01:00

Fixed weird way for detecting big/little endian platforms.

This commit is contained in:
2021-06-25 19:59:47 +02:00
parent 47d9fda3b0
commit dc6a5f95af

View File

@@ -1,6 +1,7 @@
import array import array
import itertools import itertools
import re import re
import sys
from ebook_converter.utils.config import OptionParser from ebook_converter.utils.config import OptionParser
from ebook_converter.utils.filenames import ascii_filename from ebook_converter.utils.filenames import ascii_filename
@@ -41,11 +42,11 @@ class LRFDocument(LRFMetaFile):
def _parse_objects(self): def _parse_objects(self):
self.objects = {} self.objects = {}
self._file.seek(self.object_index_offset) self._file.seek(self.object_index_offset)
obj_array = array.array("I", obj_array = array.array("I", self._file.read(4 * 4 *
self._file.read(4 * 4 * self.number_of_objects))
self.number_of_objects)) if sys.byteorder == 'big':
if ord(array.array("i", [1]).tostring()[0:1]) == 0: # big-endian
obj_array.byteswap() obj_array.byteswap()
for i in range(self.number_of_objects): for i in range(self.number_of_objects):
if not self.keep_parsing: if not self.keep_parsing:
break break