File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,13 +94,13 @@ public function __construct(string $database)
9494 }
9595 $ this ->fileHandle = $ fileHandle ;
9696
97- $ fileSize = @ filesize ( $ database );
98- if ($ fileSize === false ) {
97+ $ fstat = fstat ( $ fileHandle );
98+ if ($ fstat === false ) {
9999 throw new \UnexpectedValueException (
100100 "Error determining the size of \"$ database \". "
101101 );
102102 }
103- $ this ->fileSize = $ fileSize ;
103+ $ this ->fileSize = $ fstat [ ' size ' ] ;
104104
105105 $ start = $ this ->findMetadataStart ($ database );
106106 $ metadataDecoder = new Decoder ($ this ->fileHandle , $ start );
@@ -332,13 +332,7 @@ private function resolveDataPointer(int $pointer)
332332 private function findMetadataStart (string $ filename ): int
333333 {
334334 $ handle = $ this ->fileHandle ;
335- $ fstat = fstat ($ handle );
336- if ($ fstat === false ) {
337- throw new InvalidDatabaseException (
338- "Error getting file information ( $ filename). "
339- );
340- }
341- $ fileSize = $ fstat ['size ' ];
335+ $ fileSize = $ this ->fileSize ;
342336 $ marker = self ::$ METADATA_START_MARKER ;
343337 $ markerLength = self ::$ METADATA_START_MARKER_LENGTH ;
344338
You can’t perform that action at this time.
0 commit comments