fix offset bug
The offset was being read after the block code, causing the offset to be off by 4 bytes.
This commit is contained in:
parent
0ded5249d8
commit
01c051ce14
@ -20,12 +20,13 @@ class Blendfile(io.FileIO):
|
|||||||
block_offsets = {}
|
block_offsets = {}
|
||||||
self.seek(self._block_start)
|
self.seek(self._block_start)
|
||||||
while True:
|
while True:
|
||||||
|
offset = self.tell()
|
||||||
# File block code; identifies type of data
|
# File block code; identifies type of data
|
||||||
block_code = self.read(4).decode("utf-8")
|
block_code = self.read(4).decode("utf-8")
|
||||||
# Empty string indicates EOF.
|
# Empty string indicates EOF.
|
||||||
if block_code == "":
|
if block_code == "":
|
||||||
break
|
break
|
||||||
block_offsets[block_code] = self.tell()
|
block_offsets[block_code] = offset
|
||||||
# Size of file block, after this header
|
# Size of file block, after this header
|
||||||
block_size = int.from_bytes(self.read(4), self.endianness)
|
block_size = int.from_bytes(self.read(4), self.endianness)
|
||||||
|
|
||||||
@ -100,7 +101,6 @@ class Blendfile(io.FileIO):
|
|||||||
raise ValueError("I/O operation on a closed file.")
|
raise ValueError("I/O operation on a closed file.")
|
||||||
|
|
||||||
# Grab SDNA index and struct count from file block header.
|
# Grab SDNA index and struct count from file block header.
|
||||||
|
|
||||||
self.seek(offset + 4 + 4 + self.pointer_size)
|
self.seek(offset + 4 + 4 + self.pointer_size)
|
||||||
sdna_index = int.from_bytes(self.read(4), self.endianness)
|
sdna_index = int.from_bytes(self.read(4), self.endianness)
|
||||||
count = int.from_bytes(self.read(4), self.endianness)
|
count = int.from_bytes(self.read(4), self.endianness)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user