Sha256: 82d9ce887f62ce99bad15e9f33ae21e8a86d154525316e733c0063bd3204cdb7

Contents?: true

Size: 972 Bytes

Versions: 25

Compression:

Stored size: 972 Bytes

Contents

# frozen_string_literal: true

#
# 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

25 entries across 25 versions & 1 rubygems

Version Path
narou-3.9.1 lib/device/library/cygwin.rb
narou-3.9.0 lib/device/library/cygwin.rb
narou-3.8.2 lib/device/library/cygwin.rb
narou-3.8.1 lib/device/library/cygwin.rb
narou-3.8.0 lib/device/library/cygwin.rb
narou-3.7.2 lib/device/library/cygwin.rb
narou-3.7.1 lib/device/library/cygwin.rb
narou-3.7.0 lib/device/library/cygwin.rb
narou-3.6.0 lib/device/library/cygwin.rb
narou-3.5.1 lib/device/library/cygwin.rb
narou-3.5.0.1 lib/device/library/cygwin.rb
narou-3.5.0 lib/device/library/cygwin.rb
narou-3.4.8 lib/device/library/cygwin.rb
narou-3.4.7.1 lib/device/library/cygwin.rb
narou-3.4.7 lib/device/library/cygwin.rb
narou-3.4.6.1 lib/device/library/cygwin.rb
narou-3.4.6 lib/device/library/cygwin.rb
narou-3.4.5 lib/device/library/cygwin.rb
narou-3.4.3 lib/device/library/cygwin.rb
narou-3.4.2 lib/device/library/cygwin.rb