Example #1
0
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
Example #2
0
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
Example #3
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
Example #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