1414from ..time import epoch2dt64 , _fill_time_gaps
1515
1616
17+ int32_max = np .iinfo (np .int32 ).max
18+
19+
1720def read_signature (
1821 filename ,
1922 userdata = True ,
@@ -163,7 +166,7 @@ def __init__(
163166 debug = debug ,
164167 dp = dual_profile ,
165168 )
166- self ._reopen (bufsize )
169+ self ._open (bufsize )
167170 self .filehead_config = self ._read_filehead_config_string ()
168171 self ._ens_pos = self ._index ["pos" ][
169172 lib ._boolarray_firstensemble_ping (self ._index )
@@ -183,7 +186,7 @@ def _calc_lastblock_iswhole(
183186 return (self ._eof - self ._ens_pos [- 1 ]) == standard_blocksize
184187
185188 def _check_nortek (self , endian ):
186- self ._reopen (10 )
189+ self ._open (10 )
187190 byts = self .f .read (2 )
188191 if endian is None :
189192 if unpack ("<" + "BB" , byts ) == (165 , 10 ):
@@ -205,8 +208,12 @@ def find_all(s, c):
205208 yield idx
206209 idx = s .find (c , idx + 1 )
207210
208- # Open the entire file
209- self ._reopen (self ._eof )
211+ # Open the entire file to find start header
212+ if self ._eof >= int32_max :
213+ init_buffer = int32_max
214+ else :
215+ init_buffer = self ._eof
216+ self ._open (init_buffer )
210217 pk = self .f .peek (1 )
211218 # Search for multiple saved headers
212219 found = [i for i in find_all (pk , b"GETCLOCKSTR" )]
@@ -216,7 +223,7 @@ def find_all(s, c):
216223 start_idx = found [- 1 ] - 11
217224 return start_idx
218225
219- def _reopen (self , bufsize = None ):
226+ def _open (self , bufsize = None ):
220227 if bufsize is None :
221228 bufsize = 1000000
222229 try :
0 commit comments