IP2Location.php
private static function findFile($file = null) {
    if (null !== $file) {
      // Get actual file path
      $rfile = realpath($file);

      // If the file cannot be found, except away
      if (false === $rfile) {
        throw new \Exception(__CLASS__ . ": Database file '{$file}' does not seem to exist.", self::EXCEPTION_DBFILE_NOT_FOUND);
      }

      return $rfile;
    } else {
      // Try to get current path
      $current = realpath(dirname(__FILE__));

	  if (false === $current) {
        throw new \Exception(__CLASS__ . ": Cannot determine current path.", self::EXCEPTION_NO_PATH);
      }
      // Try each database in turn
      foreach (self::$databases as $database) {
        $rfile = realpath("{$current}/{$database}.BIN");
        if (false !== $rfile) {
          return $rfile;
        }
      }
      // No candidates found
      throw new \Exception(__CLASS__ . ": No candidate database files found.", self::EXCEPTION_NO_CANDIDATES);
    }
  }
private static function findFile($file = null) {
    if (null !== $file) {
      // Get actual file path
      $rfile = realpath($file);

      // If the file cannot be found, except away
      if (false === $rfile) {
        throw new \Exception(__CLASS__ . ": Database file '{$file}' does not seem to exist.", self::EXCEPTION_DBFILE_NOT_FOUND);
      }

      return $rfile;
    } else {
      // Try to get current path
      $current = realpath(dirname(__FILE__));

	  if (false === $current) {
        throw new \Exception(__CLASS__ . ": Cannot determine current path.", self::EXCEPTION_NO_PATH);
      }
      // Try each database in turn
      foreach (self::$databases as $database) {
        $rfile = realpath("{$current}/{$database}.BIN");
        if (false !== $rfile) {
          return $rfile;
        }
      }
      // No candidates found
      throw new \Exception(__CLASS__ . ": No candidate database files found.", self::EXCEPTION_NO_CANDIDATES);
    }
  }
private static function findFile ( $ file = null ) { if ( null !== $ file ) { // Get actual file path $ rfile = realpath ( $ file ) ; // If the file cannot be found, except away if ( false === $ rfile ) { throw new \ Exception ( __CLASS__ . ": Database file '{$file}' does not seem to exist." , self :: EXCEPTION_DBFILE_NOT_FOUND ) ; } return $ rfile ; } else { // Try to get current path $ current = realpath ( dirname ( __FILE__ ) ) ; if ( false === $ current ) { throw new \ Exception ( __CLASS__ . ": Cannot determine current path." , self :: EXCEPTION_NO_PATH ) ; } // Try each database in turn foreach ( self :: $ databases as $ database ) { $ rfile = realpath ( "{$current}/{$database}.BIN" ) ; if ( false !== $ rfile ) { return $ rfile ; } } // No candidates found throw new \ Exception ( __CLASS__ . ": No candidate database files found." , self :: EXCEPTION_NO_CANDIDATES ) ; } }
Return the realpath of the given file or look for the first matching database option

@param string $file  File to try to find, or null to try the databases in turn on the current file's path
@return string
@throws \Exception
Return the realpath of the given file or look for the first matching database option