Sha256: 3e09fc90b622c7d56b85199b4e744370bc5969f0309de430749a090d3bba1a01

Contents?: true

Size: 965 Bytes

Versions: 62

Compression:

Stored size: 965 Bytes

Contents

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

module Device::Library
  module Cygwin
    def get_device_root_dir(volume_name)
      # cygwinのドライブマウント先のpath prefixを取得する。
      # 1.7.28では二行目の行頭
      mount_root = `mount -p`.split("\n").last.split(/\s+/).first

      Dir.glob("#{mount_root}/*") do |drive_path|
        drive   = drive_path.sub(/.*\//,"")
        # windowsのvolコマンドを利用してがんばってvolume_nameを探す。
        # 一行目にボリュームラベルが含まれる。
        # volume_nameが "volume" とか "hoge(*)" などだとはまる。
        cmd     = "cmd /c vol #{drive}:".encode(Encoding::Windows_31J)
        capture = `#{cmd}`.force_encoding(Encoding::Windows_31J).encode(Encoding::UTF_8)
        if capture.split("\n").first.match(/#{volume_name}/i)
          return drive_path
        end
      end
      nil
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
narou-3.2.5.1 lib/device/library/cygwin.rb
narou-3.2.5 lib/device/library/cygwin.rb
narou-3.2.4 lib/device/library/cygwin.rb
narou-3.2.3 lib/device/library/cygwin.rb
narou-3.2.2 lib/device/library/cygwin.rb
narou-3.2.1 lib/device/library/cygwin.rb
narou-3.2.0.1 lib/device/library/cygwin.rb
narou-3.2.0 lib/device/library/cygwin.rb
narou-3.1.11 lib/device/library/cygwin.rb
narou-3.1.10 lib/device/library/cygwin.rb
narou-3.1.9 lib/device/library/cygwin.rb
narou-3.1.8 lib/device/library/cygwin.rb
narou-3.1.7 lib/device/library/cygwin.rb
narou-3.1.6 lib/device/library/cygwin.rb
narou-3.1.5 lib/device/library/cygwin.rb
narou-3.1.4 lib/device/library/cygwin.rb
narou-3.1.3 lib/device/library/cygwin.rb
narou-3.1.2 lib/device/library/cygwin.rb
narou-3.1.1 lib/device/library/cygwin.rb
narou-3.0.5.1 lib/device/library/cygwin.rb