diff --git a/bw_file.py b/bw_file.py index e0c7894..1e0c2df 100644 --- a/bw_file.py +++ b/bw_file.py @@ -107,6 +107,12 @@ def decode(self, bytecode, meta_only = False): bytecode.set_string_mode() self.header = bytecode.read_str(40) if self.header[:4] == 'BtWg' and int(self.header[4:40], 16): + if self.header[7] == '2': + if bytecode.contents_len < 60: + return + bytecode.reset_pos() + self.header = bytecode.read_str(60) + if self.header[11] == '2' or self.header[11] == '0': bytecode.set_string_mode(self.header[11]) self.meta.decode(bytecode) @@ -140,6 +146,13 @@ def export(self, path): from pytwig.src.lib import fs fs.write(path, self.serialize().replace('":', '" :')) + def read_bytes(self, bytes, raw = True, meta_only = False): + bytecode = BW_Bytecode().set_contents(bytes) + bytecode.raw = raw + bytecode.debug_obj = self + #self.num_spaces = 0 + self.decode(bytecode, meta_only = meta_only) + def read(self, path, raw = True, meta_only = False): from pytwig.src.lib import fs bytecode = BW_Bytecode().set_contents(fs.read_binary(path))