Пример #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
Пример #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
Пример #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
Пример #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