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.0.5 lib/device/library/cygwin.rb
narou-3.0.4 lib/device/library/cygwin.rb
narou-3.0.3 lib/device/library/cygwin.rb
narou-3.0.2 lib/device/library/cygwin.rb
narou-3.0.1 lib/device/library/cygwin.rb
narou-3.0.0 lib/device/library/cygwin.rb
narou-2.9.5 lib/device/library/cygwin.rb
narou-2.9.4 lib/device/library/cygwin.rb
narou-2.9.3.1 lib/device/library/cygwin.rb
narou-2.9.3 lib/device/library/cygwin.rb
narou-2.9.2 lib/device/library/cygwin.rb
narou-2.9.1 lib/device/library/cygwin.rb
narou-2.9.0 lib/device/library/cygwin.rb
narou-2.8.3.1 lib/device/library/cygwin.rb
narou-2.8.3 lib/device/library/cygwin.rb
narou-2.8.2 lib/device/library/cygwin.rb
narou-2.8.1 lib/device/library/cygwin.rb
narou-2.8.0 lib/device/library/cygwin.rb
narou-2.7.2 lib/device/library/cygwin.rb
narou-2.7.1 lib/device/library/cygwin.rb