#!/usr/bin/python # Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """A simple utility function to produce data pack files. See base/pack_file* for details. """ import struct FILE_FORMAT_VERSION = 3 HEADER_LENGTH = 2 * 4 # Two uint32s. (file version and number of entries) class WrongFileVersion(Exception): pass def ReadDataPack(input_file): """Reads a data pack file and returns a dictionary.""" data = open(input_file, "rb").read() original_data = data # Read the header. version, num_entries = struct.unpack("data into output_file as a data pack.""" ids = sorted(resources.keys()) file = open(output_file, "wb") # Write file header. file.write(struct.pack("