12
12
import struct
13
13
import re
14
14
import os
15
+ import os .path
15
16
import base64
16
17
import httplib
17
18
import sys
@@ -115,19 +116,20 @@ def __init__(self, settings, blkindex, blkmap):
115
116
self .setFileTime = True
116
117
if settings ['split_timestamp' ] != 0 :
117
118
self .timestampSplit = True
118
- # Extents and cache for out-of-order blocks
119
+ # Extents and cache for out-of-order blocks
119
120
self .blockExtents = {}
120
121
self .outOfOrderData = {}
121
122
self .outOfOrderSize = 0 # running total size for items in outOfOrderData
122
123
123
124
def writeBlock (self , inhdr , blk_hdr , rawblock ):
124
- if not self .fileOutput and ((self .outsz + self .inLen ) > self .maxOutSz ):
125
+ blockSizeOnDisk = len (inhdr ) + len (blk_hdr ) + len (rawblock )
126
+ if not self .fileOutput and ((self .outsz + blockSizeOnDisk ) > self .maxOutSz ):
125
127
self .outF .close ()
126
128
if self .setFileTime :
127
129
os .utime (outFname , (int (time .time ()), highTS ))
128
130
self .outF = None
129
131
self .outFname = None
130
- self .outFn = outFn + 1
132
+ self .outFn = self . outFn + 1
131
133
self .outsz = 0
132
134
133
135
(blkDate , blkTS ) = get_blk_dt (blk_hdr )
@@ -147,7 +149,7 @@ def writeBlock(self, inhdr, blk_hdr, rawblock):
147
149
if self .fileOutput :
148
150
outFname = self .settings ['output_file' ]
149
151
else :
150
- outFname = "%s/blk%05d.dat" % (self .settings ['output' ], outFn )
152
+ outFname = os . path . join (self .settings ['output' ], "blk%05d.dat" % self . outFn )
151
153
print ("Output file " + outFname )
152
154
self .outF = open (outFname , "wb" )
153
155
@@ -165,7 +167,7 @@ def writeBlock(self, inhdr, blk_hdr, rawblock):
165
167
(self .blkCountIn , self .blkCountOut , len (self .blkindex ), 100.0 * self .blkCountOut / len (self .blkindex )))
166
168
167
169
def inFileName (self , fn ):
168
- return "%s/blk%05d.dat" % (self .settings ['input' ], fn )
170
+ return os . path . join (self .settings ['input' ], "blk%05d.dat" % fn )
169
171
170
172
def fetchBlock (self , extent ):
171
173
'''Fetch block contents from disk given extents'''
0 commit comments