Sha256: 945c4108d47411ea4977b310e5d911388784b2e7a950fa57602abcd9b68dbc4a

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 Bytes

Contents

module VirtDisk
  class FileIo
    attr_accessor :path
    alias_method :file_name, :path

    include LogDecorator::Logging
    include ExportMethods

    export :path, :file_name

    def initialize(path, *args)
      @path      = path
      @file_lock = Mutex.new

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

    def size
      @file.size
    end
    export :size

    def close
      @file.close
    end

    def mod_read(start, len)
      @file_lock.synchronize do
        @file.seek start
        @file.read len
      end
    end

    def mod_write(buf, start, len)
      @file_lock.synchronize do
        @file.seek start
        @file.write buf, len
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
virt_disk-0.0.1 lib/virt_disk/file_io.rb