class QuartzTorrent::IOManager

Basic IOManager that isn’t used by a reactor.

Public Class Methods

new() click to toggle source
# File lib/quartz_torrent/filemanager.rb, line 116
def initialize
  @io = {}
end

Public Instance Methods

flush() click to toggle source
# File lib/quartz_torrent/filemanager.rb, line 137
def flush
  @io.each do |k,v|
    v.flush
  end
end
get(path) click to toggle source
# File lib/quartz_torrent/filemanager.rb, line 120
def get(path)
  @io[path]
end
open(path) click to toggle source
# File lib/quartz_torrent/filemanager.rb, line 124
def open(path)
  # Open the file for read/write.
  # If the file exists, open as r+ so it is not truncated.
  # Otherwise open as w+
  if File.exists?(path)
    io = File.open(path, "rb+")
  else
    io = File.open(path, "wb+")
  end
  @io[path] = io
  io
end