class VirtDisk::FileIo

Attributes

file_name[RW]
path[RW]

Public Class Methods

new(path, *args) click to toggle source
# File lib/virt_disk/file_io.rb, line 11
def initialize(path, *args)
  @path      = path
  @file_lock = Mutex.new

  _log.debug "Opening file - #{path}"
  @file = File.open(path, *args)
end

Public Instance Methods

close() click to toggle source
# File lib/virt_disk/file_io.rb, line 24
def close
  @file.close
end
mod_read(start, len) click to toggle source
# File lib/virt_disk/file_io.rb, line 28
def mod_read(start, len)
  @file_lock.synchronize do
    @file.seek start
    @file.read len
  end
end
mod_write(buf, start, len) click to toggle source
# File lib/virt_disk/file_io.rb, line 35
def mod_write(buf, start, len)
  @file_lock.synchronize do
    @file.seek start
    @file.write buf, len
  end
end
size() click to toggle source
# File lib/virt_disk/file_io.rb, line 19
def size
  @file.size
end