Class: Chef::Util::Windows::NetUse
- Inherits:
-
Chef::Util::Windows
- Object
- Chef::Util::Windows
- Chef::Util::Windows::NetUse
- Defined in:
- lib/chef/util/windows/net_use.rb
Instance Method Summary collapse
- #add(args) ⇒ Object
-
#delete ⇒ Object
XXX should we use some FORCE here?.
- #device ⇒ Object
- #get_info ⇒ Object
-
#initialize(localname) ⇒ NetUse
constructor
A new instance of NetUse.
Constructor Details
#initialize(localname) ⇒ NetUse
Returns a new instance of NetUse.
76 77 78 79 |
# File 'lib/chef/util/windows/net_use.rb', line 76 def initialize(localname) @localname = localname @name = multi_to_wide(localname) end |
Instance Method Details
#add(args) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/chef/util/windows/net_use.rb', line 81 def add(args) if args.class == String remote = args args = Hash.new args[:remote] = remote end args[:local] ||= @localname use = use_info_2(args) buffer = use_info_2_pack(use) rc = NetUseAdd.call(nil, 2, buffer, nil) if rc != NERR_Success raise ArgumentError, get_last_error(rc) end end |
#delete ⇒ Object
XXX should we use some FORCE here?
115 116 117 118 119 120 |
# File 'lib/chef/util/windows/net_use.rb', line 115 def delete rc = NetUseDel.call(nil, @name, USE_NOFORCE) if rc != NERR_Success raise ArgumentError, get_last_error(rc) end end |
#device ⇒ Object
111 112 113 |
# File 'lib/chef/util/windows/net_use.rb', line 111 def device get_info()[:remote] end |
#get_info ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/chef/util/windows/net_use.rb', line 96 def get_info ptr = 0.chr * PTR_SIZE rc = NetUseGetInfo.call(nil, @name, 2, ptr) if rc != NERR_Success raise ArgumentError, get_last_error(rc) end ptr = ptr.unpack('L')[0] buffer = 0.chr * SIZEOF_USE_INFO_2 memcpy(buffer, ptr, buffer.size) NetApiBufferFree(ptr) use_info_2_unpack(buffer) end |