Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Unified Diff: tools/data_pack/data_pack.py

Issue 7555003: Update the .pak file format to version 2: Make resource ids 16bit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: evan's review feedback Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.cc ('k') | tools/grit/grit/format/data_pack.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/data_pack/data_pack.py
diff --git a/tools/data_pack/data_pack.py b/tools/data_pack/data_pack.py
index fde94835fc97df4e96309d32df64cb1acf6ab4d1..571842eabea967f6d36f4200cbc1154b824ff236 100755
--- a/tools/data_pack/data_pack.py
+++ b/tools/data_pack/data_pack.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright (c) 2008 The Chromium Authors. All rights reserved.
+# 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.
@@ -9,7 +9,7 @@ See base/pack_file* for details.
import struct
-FILE_FORMAT_VERSION = 1
+FILE_FORMAT_VERSION = 2
HEADER_LENGTH = 2 * 4 # Two uint32s. (file version and number of entries)
class WrongFileVersion(Exception):
@@ -28,9 +28,9 @@ def ReadDataPack(input_file):
resources = {}
# Read the index and data.
data = data[HEADER_LENGTH:]
- kIndexEntrySize = 3 * 4 # Each entry is 3 uint32s.
+ kIndexEntrySize = 2 + 2 * 4 # Each entry is 1 uint16 and 2 uint32s.
for _ in range(num_entries):
- id, offset, length = struct.unpack("<III", data[:kIndexEntrySize])
+ id, offset, length = struct.unpack("<HII", data[:kIndexEntrySize])
data = data[kIndexEntrySize:]
resources[id] = original_data[offset:offset + length]
@@ -44,12 +44,13 @@ def WriteDataPack(resources, output_file):
# Write file header.
file.write(struct.pack("<II", FILE_FORMAT_VERSION, len(ids)))
- index_length = len(ids) * 3 * 4 # Each entry is 3 uint32s.
+ # Each entry is 1 uint16 and 2 uint32s.
+ index_length = len(ids) * (2 + 2 * 4)
# Write index.
data_offset = HEADER_LENGTH + index_length
for id in ids:
- file.write(struct.pack("<III", id, data_offset, len(resources[id])))
+ file.write(struct.pack("<HII", id, data_offset, len(resources[id])))
data_offset += len(resources[id])
# Write data.
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.cc ('k') | tools/grit/grit/format/data_pack.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698