Skip to content

Commit

Permalink
[Normal] Update Some Codes
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdWindScholar committed Feb 13, 2024
1 parent 323ee1b commit feadf81
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions lpunpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,19 +620,6 @@ def _read_data(self, chunk_data_size: int):

return self._fd.read(chunk_data_size)

@staticmethod
def split(num):
block = 10000000
while True:
if num > block:
yield struct.pack("B", 0) * block
num -= block
else:
if num > 0:
return struct.pack("B", 0) * num
else:
break

def unsparse(self):
if not self.header:
self._fd.seek(0)
Expand Down Expand Up @@ -660,31 +647,19 @@ def unsparse(self):
if chunk_header.chunk_type == 0xCAC2:
data = self._read_data(chunk_data_size)
len_data = sector_size << 9
try:
out.write(struct.pack("B", 0) * len_data)
except (BaseException, Exception):
for i in self.split(len_data):
out.write(i)
out.write(struct.pack("B", 0) * len_data)
output_len += len(data)
sector_base += sector_size
else:
if chunk_header.chunk_type == 0xCAC3:
data = self._read_data(chunk_data_size)
len_data = sector_size << 9
try:
out.write(struct.pack("B", 0) * len_data)
except (BaseException, Exception):
for i in self.split(len_data):
out.write(i)
out.write(struct.pack("B", 0) * len_data)
output_len += len(data)
sector_base += sector_size
else:
len_data = sector_size << 9
try:
out.write(struct.pack("B", 0) * len_data)
except (BaseException, Exception):
for i in self.split(len_data):
out.write(i)
out.write(struct.pack("B", 0) * len_data)
sector_base += sector_size
chunks -= 1
return unsparse_file
Expand Down

0 comments on commit feadf81

Please sign in to comment.