aboutsummaryrefslogtreecommitdiffstats
path: root/FuseArchive/Chunk.py
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2009-08-04 18:07:09 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2009-08-04 18:07:09 (GMT)
commitdb8e7858692e9157b6dc9ac2471b62c40f5ff12f (patch)
treeaa273a43967d3736d3702694af8c1023cc26ebb0 /FuseArchive/Chunk.py
parent642fc898d83e5b534cbd957381ae884b853c35c9 (diff)
downloadfusearchive-db8e7858692e9157b6dc9ac2471b62c40f5ff12f.zip
fusearchive-db8e7858692e9157b6dc9ac2471b62c40f5ff12f.tar.gz
fusearchive-db8e7858692e9157b6dc9ac2471b62c40f5ff12f.tar.bz2
Made header length a variable so we can change it later if needed
Diffstat (limited to 'FuseArchive/Chunk.py')
-rw-r--r--FuseArchive/Chunk.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/FuseArchive/Chunk.py b/FuseArchive/Chunk.py
index 9f12f83..9bb05bd 100644
--- a/FuseArchive/Chunk.py
+++ b/FuseArchive/Chunk.py
@@ -8,7 +8,9 @@ import struct, zlib, logging
hformat = 'HLBL48x'
compress_level = 6
-assert struct.calcsize( hformat ) == 64, \
+header_length = 64
+
+assert struct.calcsize( hformat ) == header_length, \
"Header struct must be 64 bytes not %d bytes" % \
struct.calcsize( hformat )
@@ -57,15 +59,15 @@ class Chunk:
@staticmethod
def deserialize(data):
logging.debug( "Deserializing data of length %d" % len( data ) )
- hd = Chunk.parse_header( data[ :64 ] )
+ hd = Chunk.parse_header( data[ :header_length ] )
obj = Chunk()
obj.count = hd[ 'count' ]
compression = hd[ 'compression' ]
if compression == 0:
- obj.chunk = data[ 64: ]
+ obj.chunk = data[ header_length: ]
elif compression == 1:
- obj.chunk = zlib.decompress( data[64: ] )
+ obj.chunk = zlib.decompress( data[ header_length: ] )
else:
raise ValueError( "Invalid compression type: %d" % compression )