Sha256: af3b1d74f2cb5e4ebe6d937678bec03894335ebca158013bc4de295242feecfe

Contents?: true

Size: 771 Bytes

Versions: 33

Compression:

Stored size: 771 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")
      drive_strings = " " * 1000
      result_len = WinAPI.GetLogicalDriveStrings(1000, drive_strings)
      drives = drive_strings[0, result_len].split("\0")
      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
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
narou-1.5.11 lib/device/library/windows.rb
narou-1.5.10.1 lib/device/library/windows.rb
narou-1.5.10 lib/device/library/windows.rb
narou-1.5.9 lib/device/library/windows.rb
narou-1.5.8 lib/device/library/windows.rb
narou-1.5.7.1 lib/device/library/windows.rb
narou-1.5.7 lib/device/library/windows.rb
narou-1.5.6.1 lib/device/library/windows.rb
narou-1.5.6 lib/device/library/windows.rb
narou-1.5.5.1 lib/device/library/windows.rb
narou-1.5.5 lib/device/library/windows.rb
narou-1.5.4 lib/device/library/windows.rb
narou-1.5.3 lib/device/library/windows.rb
narou-1.5.2.1 lib/device/library/windows.rb
narou-1.5.2 lib/device/library/windows.rb
narou-1.5.1 lib/device/library/windows.rb
narou-1.5.0.2 lib/device/library/windows.rb
narou-1.5.0.1 lib/device/library/windows.rb
narou-1.5.0 lib/device/library/windows.rb
narou-1.4.6 lib/device/library/windows.rb