Class: Chef::Util::Windows::Volume

Inherits:
Chef::Util::Windows show all
Includes:
Windows::Volume
Defined in:
lib/chef/util/windows/volume.rb

Constant Summary collapse

DeleteVolumeMountPoint =

XXX not defined in the current windows-pr release

Windows::API.new('DeleteVolumeMountPoint', 'S', 'B')

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Volume

Returns a new instance of Volume.



34
35
36
37
# File 'lib/chef/util/windows/volume.rb', line 34

def initialize(name)
  name += "\\" unless name =~ /\\$/ #trailing slash required
  @name = name
end

Instance Method Details

#add(device) ⇒ Object



54
55
56
57
58
# File 'lib/chef/util/windows/volume.rb', line 54

def add(device)
  unless SetVolumeMountPoint(@name, device)
    raise ArgumentError, get_last_error
  end
end

#deleteObject



48
49
50
51
52
# File 'lib/chef/util/windows/volume.rb', line 48

def delete
  unless DeleteVolumeMountPoint.call(@name)
    raise ArgumentError, get_last_error
  end
end

#deviceObject



39
40
41
42
43
44
45
46
# File 'lib/chef/util/windows/volume.rb', line 39

def device
  buffer = 0.chr * 256
  if GetVolumeNameForVolumeMountPoint(@name, buffer, buffer.size)
    return buffer[0,buffer.size].unpack("Z*")[0]
  else
    raise ArgumentError, get_last_error
  end
end