Sha256: 948845fdcb4f0403534382e38aaf1e346851be89b627cf5e09f542aac45109c8

Contents?: true

Size: 915 Bytes

Versions: 53

Compression:

Stored size: 915 Bytes

Contents

require 'sys-uname'
require 'util/miq-system'

if Sys::Platform::IMPL == :linux && MiqSystem.arch == :x86_64
  require 'linux_block_device'
  require 'disk/modules/RawBlockIO'
end

module MiqLargeFile
  def self.open(file_name, flags)
    if Sys::Platform::IMPL == :linux && MiqLargeFileStat.new(file_name).blockdev?
      RawBlockIO.new(file_name, flags)
    else
      MiqLargeFileOther.new(file_name, flags)
    end
  end

  def self.size(file_name)
    f = open(file_name, "r")
    s = f.size
    f.close
    s
  end

  # For camcorder interposition.
  class MiqLargeFileStat
    def initialize(file_name)
      @file_name = file_name
    end

    def blockdev?
      File.stat(@file_name).blockdev?
    end
  end

  class MiqLargeFileOther < File
    def write(buf, _len)
      super(buf)
    end

    def size
      return stat.size unless stat.blockdev?
      LinuxBlockDevice.size(fileno)
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
manageiq-smartstate-0.8.1 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.8.0 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.7.0 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.6.2 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.5.10 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.3.10 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.6.1 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.3.9 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.6.0 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.5.9 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.5.8 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.3.8 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.5.7 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.3.7 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.5.6 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.3.6 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.5.5 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.5.4 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.3.5 lib/disk/modules/MiqLargeFile.rb
manageiq-smartstate-0.5.3 lib/disk/modules/MiqLargeFile.rb