You are here

class Util in Smart IP 6.2

Same name and namespace in other branches
  1. 7.2 includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Util.php \MaxMind\Db\Reader\Util

Hierarchy

  • class \MaxMind\Db\Reader\Util

Expanded class hierarchy of Util

2 files declare their use of Util
Decoder.php in includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php
Reader.php in includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader.php

File

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

Namespace

MaxMind\Db\Reader
View source
class Util {
  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");
  }

}

Members