You are here

public static function Util::read in Smart IP 7.2

Same name and namespace in other branches
  1. 6.2 includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Util.php \MaxMind\Db\Reader\Util::read()
5 calls to Util::read()
Decoder::decode in includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php
Decoder::decodeByType in includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php
Decoder::decodePointer in includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php
Decoder::sizeFromCtrlByte in includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php
Reader::readNode in includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader.php

File

includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Util.php, line 9

Class

Util

Namespace

MaxMind\Db\Reader

Code

public static function read($stream, $offset, $numberOfBytes) {
  if ($numberOfBytes == 0) {
    return '';
  }
  if (fseek($stream, $offset) == 0) {
    $value = fread($stream, $numberOfBytes);

    // We check that the number of bytes read is equal to the number
    // asked for. We use ftell as getting the length of $value is
    // much slower.
    if (ftell($stream) - $offset === $numberOfBytes) {
      return $value;
    }
  }
  throw new InvalidDatabaseException("The MaxMind DB file contains bad data");
}