Class: MaxMind::DB::FileReader::PReadFile

Inherits:
Object
  • Object
show all
Defined in:
lib/maxmind/db/file_reader.rb

Overview

For Windows support

Instance Method Summary collapse

Constructor Details

#initialize(filename, mode) ⇒ PReadFile

Returns a new instance of PReadFile.



14
15
16
17
# File 'lib/maxmind/db/file_reader.rb', line 14

def initialize(filename, mode)
  @mutex = Mutex.new
  @file = File.new(filename, mode)
end

Instance Method Details

#closeObject



23
24
25
# File 'lib/maxmind/db/file_reader.rb', line 23

def close
  @file.close
end

#pread(size, offset) ⇒ Object



27
28
29
30
31
32
# File 'lib/maxmind/db/file_reader.rb', line 27

def pread(size, offset)
  @mutex.synchronize do
    @file.seek(offset, IO::SEEK_SET)
    @file.read(size)
  end
end

#sizeObject



19
20
21
# File 'lib/maxmind/db/file_reader.rb', line 19

def size
  @file.size
end