aboutsummaryrefslogtreecommitdiffstats
path: root/FuseArchive
diff options
context:
space:
mode:
Diffstat (limited to 'FuseArchive')
-rw-r--r--FuseArchive/ChunkBuffer.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/FuseArchive/ChunkBuffer.py b/FuseArchive/ChunkBuffer.py
index 4ef6370..7b6beee 100644
--- a/FuseArchive/ChunkBuffer.py
+++ b/FuseArchive/ChunkBuffer.py
@@ -5,16 +5,31 @@ import logging
class ChunkBuffer:
def __init__( self, data = '' ):
logging.debug( "Creating chunkbuffer: %s" % data )
- self.chunk = list( data )
+ self.chunk = [ data ]
def append( self, s ):
- self.chunk.extend( list( s ) )
+ self.chunk.append( s )
- def replace( self, s, start, end ):
- self.chunk
+ def replace( self, buf, start, end ):
+ # We make a string of our chunk, then create a new list of the 3
+ # strings, the start, new chunk, and remaining chunk
+ s = ''.join( self.chunk )
+ l = end - start
+ self.chunk = [ s[ :start ], buf[ :l ], s[ end: ] ]
def length( self ):
- return len( self.chunk )
+ if len( self.chunk ) > 5:
+ self._simplify()
+
+ l = 0;
+ for c in self.chunk:
+ l += len( c )
+
+ return l
+
+ def _simplify( self ):
+ logging.debug( "Simplify!" )
+ self.chunk = [ ''.join( self.chunk ) ]
def string(self):
logging.debug( "Stringifying: %s" % self.chunk )