Sha256: 58db4ec354ff81bed231df3412a4b734681a4ba62f41f03d9db4c4c5d7a1d235

Contents?: true

Size: 803 Bytes

Versions: 35

Compression:

Stored size: 803 Bytes

Contents

# -*- coding: utf-8 -*-
#
# Copyright 2013 whiteleaf. All rights reserved.
#

require "win32ole"
require_relative "../../extensions/windows"

module Device::Library
  module Windows
    def get_device_root_dir(volume_name)
      @@FileSystemObject ||= WIN32OLE.new("Scripting.FileSystemObject")
      get_drives.each do |drive_letter|
        drive_info = @@FileSystemObject.GetDrive(drive_letter)
        vol = drive_info.VolumeName rescue ""
        if vol.downcase == volume_name.downcase
          return File.expand_path(drive_letter)
        end
      end
      nil
    end

    def get_drives
      result = []
      bits = WinAPI.GetLogicalDrives
      26.times do |i|
        if bits & (1 << i) != 0
          result << "#{(65 + i).chr}:\\"
        end
      end
      result
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
narou-2.9.4 lib/device/library/windows.rb
narou-2.9.3.1 lib/device/library/windows.rb
narou-2.9.3 lib/device/library/windows.rb
narou-2.9.2 lib/device/library/windows.rb
narou-2.9.1 lib/device/library/windows.rb
narou-2.9.0 lib/device/library/windows.rb
narou-2.8.3.1 lib/device/library/windows.rb
narou-2.8.3 lib/device/library/windows.rb
narou-2.8.2 lib/device/library/windows.rb
narou-2.8.1 lib/device/library/windows.rb
narou-2.8.0 lib/device/library/windows.rb
narou-2.7.2 lib/device/library/windows.rb
narou-2.7.1 lib/device/library/windows.rb
narou-2.7.0 lib/device/library/windows.rb
narou-2.6.1 lib/device/library/windows.rb
narou-2.6.0 lib/device/library/windows.rb
narou-2.5.2 lib/device/library/windows.rb
narou-2.5.1 lib/device/library/windows.rb
narou-2.4.2 lib/device/library/windows.rb
narou-2.4.1 lib/device/library/windows.rb