Skip to content

Commit

Permalink
(PUP-2738) Windows::File use FFI::Pointer helper
Browse files Browse the repository at this point in the history
 - Remove custom packing of array bytes and replace with use of
   read_wide_string from FFI::Pointer
  • Loading branch information
Iristyle committed Jun 18, 2014
1 parent fdffe84 commit b5267d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/util/windows/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ def self.resolve_symlink(handle)
offset = reparse_data[:PrintNameOffset]
length = reparse_data[:PrintNameLength]

path = reparse_data[:PathBuffer].to_a[offset, length].pack('C*')
path = path.force_encoding('UTF-16LE').encode(Encoding.default_external)
ptr = reparse_data.pointer + reparse_data.offset_of(:PathBuffer) + offset
path = ptr.read_wide_string(length / 2) # length is bytes, need UTF-16 wchars
end

path
Expand Down

0 comments on commit b5267d1

Please sign in to comment.