Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/MaxMind/Db/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public function __construct(string $database)
}
$this->fileHandle = $fileHandle;

$fileSize = @filesize($database);
if ($fileSize === false) {
$fstat = fstat($fileHandle);
if ($fstat === false) {
throw new \UnexpectedValueException(
"Error determining the size of \"$database\"."
);
}
$this->fileSize = $fileSize;
$this->fileSize = $fstat['size'];

$start = $this->findMetadataStart($database);
$metadataDecoder = new Decoder($this->fileHandle, $start);
Expand Down Expand Up @@ -332,13 +332,7 @@ private function resolveDataPointer(int $pointer)
private function findMetadataStart(string $filename): int
{
$handle = $this->fileHandle;
$fstat = fstat($handle);
if ($fstat === false) {
throw new InvalidDatabaseException(
"Error getting file information ($filename)."
);
}
$fileSize = $fstat['size'];
$fileSize = $this->fileSize;
$marker = self::$METADATA_START_MARKER;
$markerLength = self::$METADATA_START_MARKER_LENGTH;

Expand Down