Sha256: f7533b613f48fde4364732d99cf4fe7166e0aaed57b3e01702b5c71cbae6b6ea

Contents?: true

Size: 992 Bytes

Versions: 20

Compression:

Stored size: 992 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

20 entries across 20 versions & 1 rubygems

Version Path
narou-1.7.1 lib/device/library/cygwin.rb
narou-1.6.4 lib/device/library/cygwin.rb
narou-1.6.3 lib/device/library/cygwin.rb
narou-1.6.1 lib/device/library/cygwin.rb
narou-1.6.0 lib/device/library/cygwin.rb
narou-1.5.11 lib/device/library/cygwin.rb
narou-1.5.10.1 lib/device/library/cygwin.rb
narou-1.5.10 lib/device/library/cygwin.rb
narou-1.5.9 lib/device/library/cygwin.rb
narou-1.5.8 lib/device/library/cygwin.rb
narou-1.5.7.1 lib/device/library/cygwin.rb
narou-1.5.7 lib/device/library/cygwin.rb
narou-1.5.6.1 lib/device/library/cygwin.rb
narou-1.5.6 lib/device/library/cygwin.rb
narou-1.5.5.1 lib/device/library/cygwin.rb
narou-1.5.5 lib/device/library/cygwin.rb
narou-1.5.4 lib/device/library/cygwin.rb
narou-1.5.3 lib/device/library/cygwin.rb
narou-1.5.2.1 lib/device/library/cygwin.rb
narou-1.5.2 lib/device/library/cygwin.rb