aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2009-07-23 21:45:31 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2009-07-23 21:45:31 (GMT)
commitc5ac8d9dfddf293db4987fd0f06068dec369f2d0 (patch)
treedecc05641e967ec91fccc90c7e9e3b551ae7caae
parent0171712a2516e638f1dd2a8e247fc44433babbd8 (diff)
downloadfusearchive-c5ac8d9dfddf293db4987fd0f06068dec369f2d0.zip
fusearchive-c5ac8d9dfddf293db4987fd0f06068dec369f2d0.tar.gz
fusearchive-c5ac8d9dfddf293db4987fd0f06068dec369f2d0.tar.bz2
Data reading seems to work
-rwxr-xr-xfusearchive.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/fusearchive.py b/fusearchive.py
index f648235..bcfed7c 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -435,21 +435,33 @@ class FuseArchive(Fuse):
+ " length: " + str( length ) )
data_read = 0
- data = None
+ data = ''
index = int( offset / self.chunk_size )
rest = offset % self.chunk_size
+ is_eof = False
# Keep reading chunks until we have at least this much data
- while data_read < length:
+ while data_read < length and not is_eof:
dmsg( 3, "Pulling chunk data" )
self._load_chunk( index )
- chunk_remaining = self.chunk_size - rest
- data += substr( self.chunk[ rest:chunk_remaining ] )
- data_read = len( data )
- index += 1
- rest = 0
+ if len(self.chunk):
+ chunk_remaining = len(self.chunk) - rest
+ to_read = chunk_remaining
+ data_left = length - data_read
+ if data_left < chunk_remaining:
+ to_read = data_left
+
+ dmsg( 3, "Copying " + str(to_read) + " bytes" )
+
+ data += self.chunk[ rest:chunk_remaining ]
+ data_read += to_read
+ index += 1
+ rest = 0
+ else:
+ dmsg( 3, "No more chunk data, bye" )
+ is_eof = True
- return data[ :length ]
+ return data
def write(self, buf, offset):
dmsg( 3, "Writing to " + self.orig_path + " offset: " + str( offset ) )