microwave 0.1004.5 → 0.1004.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,59 +0,0 @@
1
- #
2
- # Author:: Doug MacEachern (<dougm@vmware.com>)
3
- # Copyright:: Copyright (c) 2010 VMware, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- #simple wrapper around Volume APIs. might be possible with WMI, but possibly more complex.
20
-
21
- require 'chef/util/windows'
22
- require 'windows/volume'
23
-
24
- class Chef::Util::Windows::Volume < Chef::Util::Windows
25
-
26
- private
27
- include Windows::Volume
28
- #XXX not defined in the current windows-pr release
29
- DeleteVolumeMountPoint =
30
- Windows::API.new('DeleteVolumeMountPoint', 'S', 'B') unless defined? DeleteVolumeMountPoint
31
-
32
- public
33
-
34
- def initialize(name)
35
- name += "\\" unless name =~ /\\$/ #trailing slash required
36
- @name = name
37
- end
38
-
39
- def device
40
- buffer = 0.chr * 256
41
- if GetVolumeNameForVolumeMountPoint(@name, buffer, buffer.size)
42
- return buffer[0,buffer.size].unpack("Z*")[0]
43
- else
44
- raise ArgumentError, get_last_error
45
- end
46
- end
47
-
48
- def delete
49
- unless DeleteVolumeMountPoint.call(@name)
50
- raise ArgumentError, get_last_error
51
- end
52
- end
53
-
54
- def add(device)
55
- unless SetVolumeMountPoint(@name, device)
56
- raise ArgumentError, get_last_error
57
- end
58
- end
59
- end