예제 #1
0
파일: pack.py 프로젝트: WalrusRPG/PIAF
def pack_filetable(archive):
    file_table = b''
    data_size = 0
    for f in archive['file_entries']:
        data_offset = data_size
        file_size = len(f["data"])
        file_table += struct.pack(file_entry_structure(), f["file_name"], f["file_type"], f["compression_type"], file_size, data_offset)
        data_size += file_size

    return file_table
예제 #2
0
파일: pack.py 프로젝트: WalrusRPG/PIAF
def pack_filetable(archive):
    file_table = b''
    data_size = 0
    for f in archive['file_entries']:
        data_offset = data_size
        file_size = len(f["data"])
        file_table += struct.pack(file_entry_structure(), f["file_name"],
                                  f["file_type"], f["compression_type"],
                                  file_size, data_offset)
        data_size += file_size

    return file_table
예제 #3
0
파일: unpack.py 프로젝트: WalrusRPG/PIAF
    def parse_filetable():
        result = []
        file_sizes = []
        for i in range(nb_files):
            file_entry_offset = header_size()+file_entry_size()*i
            file_name, file_type, compression_type, file_size, data_offset =\
		struct.unpack(
	                file_entry_structure(),
                	buffer[ file_entry_offset: file_entry_offset+file_entry_size()]
                )

            file_entry = { "file_type": file_type,
                           "compression_type": compression_type }

            result.append(file_entry)
            file_sizes.append(file_size)
        return result, file_sizes
예제 #4
0
    def parse_filetable():
        result = []
        file_sizes = []
        for i in range(nb_files):
            file_entry_offset = header_size() + file_entry_size() * i
            file_name, file_type, compression_type, file_size, data_offset =\
  struct.unpack(
                 file_entry_structure(),
                 buffer[ file_entry_offset: file_entry_offset+file_entry_size()]
                )

            file_entry = {
                "file_type": file_type,
                "compression_type": compression_type
            }

            result.append(file_entry)
            file_sizes.append(file_size)
        return result, file_sizes