@@ -125,7 +125,7 @@ class FileStream extends Stream {
125
125
function __construct ($ file ) {
126
126
$ this ->f = fopen ($ file , 'rb+ ' );
127
127
if ($ this ->f === false ) {
128
- throw 'Unable to open file ' ;
128
+ throw new Exception ( 'Unable to open file ' ) ;
129
129
}
130
130
$ this ->size = filesize ($ file );
131
131
}
@@ -137,7 +137,10 @@ protected function read($length) {
137
137
}
138
138
public function write ($ newData ) {
139
139
fwrite ($ this ->f , $ newData );
140
- $ this ->size += strlen ($ newData );
140
+ $ pos = $ this ->position ;
141
+ fseek ($ this ->f , 0 , SEEK_END );
142
+ $ this ->size = ftell ($ this ->f );
143
+ $ this ->position = $ pos ;
141
144
}
142
145
public function seek ($ position ) {
143
146
fseek ($ this ->f , $ position );
@@ -269,8 +272,11 @@ function extractBundle($bundle) {
269
272
$ bundle ->position = $ nextFile ;
270
273
}
271
274
return $ fileList ;
275
+ } else if ($ format == 6 ) {
276
+ } else if ($ format == 7 ) {
277
+ } else {
278
+ throw new Exception ('unknown version: ' .$ format );
272
279
}
273
- if ($ format != 6 ) throw new Exception ('unknown version: ' .$ format );
274
280
275
281
$ bundle ->longlong ;
276
282
$ compressedSize = $ bundle ->long ;
@@ -280,6 +286,9 @@ function extractBundle($bundle) {
280
286
if (($ flag & 128 ) != 0 ) {
281
287
throw new Exception ('block info at end ' );
282
288
} else {
289
+ if ($ format == 7 ) {
290
+ $ bundle ->alignStream (16 );
291
+ }
283
292
$ blocksInfoBytes = $ bundle ->readData ($ compressedSize );
284
293
}
285
294
0 commit comments