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

Unified Diff: tools/grit/grit/format/data_pack.py

Issue 7604012: Remove the length field from the index entries in data pack files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix write Created 9 years, 4 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 | « tools/data_pack/data_pack.py ('k') | tools/grit/grit/format/data_pack_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/format/data_pack.py
diff --git a/tools/grit/grit/format/data_pack.py b/tools/grit/grit/format/data_pack.py
index 112c13e2834ffe44da88cdbb7aab68bd59a529c0..993ecf63fd127f3709eb5c26500cb366ebc209d1 100755
--- a/tools/grit/grit/format/data_pack.py
+++ b/tools/grit/grit/format/data_pack.py
@@ -15,7 +15,7 @@ from grit.node import message
from grit.node import misc
-PACK_FILE_VERSION = 2
+PACK_FILE_VERSION = 3
class DataPack(interface.ItemFormatter):
@@ -60,15 +60,18 @@ class DataPack(interface.ItemFormatter):
ret.append(struct.pack("<II", PACK_FILE_VERSION, len(ids)))
HEADER_LENGTH = 2 * 4 # Two uint32s.
- # Each entry is 1 uint16 + 2 uint32s.
- index_length = len(ids) * (2 + 2 * 4)
+ # Each entry is a uint16 + a uint32s. We have one extra entry for the last
+ # item.
+ index_length = (len(ids) + 1) * (2 + 4)
# Write index.
data_offset = HEADER_LENGTH + index_length
for id in ids:
- ret.append(struct.pack("<HII", id, data_offset, len(resources[id])))
+ ret.append(struct.pack("<HI", id, data_offset))
data_offset += len(resources[id])
+ ret.append(struct.pack("<HI", 0, data_offset))
+
# Write data.
for id in ids:
ret.append(resources[id])
« no previous file with comments | « tools/data_pack/data_pack.py ('k') | tools/grit/grit/format/data_pack_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698