Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports ---------------------------------------------------------------------
- import struct
- import io
- path = 'Save70_A3AA8A36M4C696C6C79_Commonwealth_010659_20170908034503_16_2.f4se'
- class FileReader(io.FileIO):
- """File-object with convenience reading functions."""
- def unpack(self, fmt):
- return struct.unpack(fmt, self.read(struct.calcsize(fmt)))
- def readUByte(self): return struct.unpack('B', self.read(1))[0]
- def readUInt16(self): return struct.unpack('H', self.read(2))[0]
- def readUInt32(self): return struct.unpack('I', self.read(4))[0]
- def readByte(self): return struct.unpack('b', self.read(1))[0]
- def readInt16(self): return struct.unpack('h', self.read(2))[0]
- def readInt32(self): return struct.unpack('i', self.read(4))[0]
- def readSig(self): return struct.unpack('4s', self.read(4))[0]
- def readString8(self): return self.read(struct.unpack('B', self.read(1))[0])
- def readString16(self): return self.read(struct.unpack('H', self.read(2))[0])
- def readString32(self): return self.read(struct.unpack('I', self.read(4))[0])
- def readChunk(file):
- chunkType = FileReader.readSig(file).decode("utf-8")
- chunkVersion = FileReader.readInt32(file)
- chunkLength = FileReader.readInt32(file)
- chunkData = file.read(chunkLength)
- chunkValue = []
- chunkValue.append(chunkType)
- chunkValue.append(chunkVersion)
- chunkValue.append(chunkLength)
- chunkValue.append(chunkData)
- print (chunkValue)
- return chunkValue
- def readChunks(file):
- opcodeBase = FileReader.readInt32(file)
- numChunks = FileReader.readInt32(file)
- pluginLength = FileReader.readInt32(file)
- chunkBlock = []
- for x in range(numChunks):
- chunkBlock.append(readChunk(file))
- return chunkBlock
- def main():
- """Main function, fires everything off."""
- cosave_file = open(path,'rb')
- signature = FileReader.readSig(cosave_file).decode("utf-8")
- formatVersion = FileReader.readInt32(cosave_file)
- obseVersion = FileReader.readInt16(cosave_file)
- obseMinorVersion = FileReader.readInt16(cosave_file)
- oblivionVersion = FileReader.readInt32(cosave_file)
- numPlugins = FileReader.readInt32(cosave_file)
- print ("Signature: ", signature)
- print ("formatVersion: ", formatVersion)
- print ("obseVersion : ", obseVersion)
- print ("obseMinorVersion: ", obseMinorVersion)
- print ("oblivionVersion: ", oblivionVersion)
- print ("numPlugins: ", numPlugins)
- for x in range(numPlugins):
- readChunks(cosave_file)
- cosave_file.close()
- if __name__=='__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement