Sha256: f460b25a9e1107bb7d7f885710547698d359989d22ea8a69c3c6265248f8bac8

Contents?: true

Size: 1.05 KB

Versions: 58

Compression:

Stored size: 1.05 KB

Contents

require "fiddle/import"

module Vagrant
  module Util
    module WindowsPath
      module API
        extend Fiddle::Importer
        dlload 'kernel32.dll'
        extern("int GetLongPathNameA(char*, char*, int)", :stdcall)
      end

      # Converts a Windows shortname to a long name. This only works
      # for ASCII paths currently and doesn't use the wide character
      # support.
      def self.longname(name)
        # We loop over the API call in case we didn't allocate enough
        # buffer space. In general it is usually enough.
        bufferlen = 250
        buffer    = nil
        while true
          buffer = ' ' * bufferlen
          len    = API.GetLongPathNameA(name.to_s, buffer, buffer.size)
          if bufferlen < len
            # If the length returned is larger than our buffer length,
            # it is the API telling us it needs more space. Allocate it
            # and retry.
            bufferlen = len
            continue
          end

          break
        end

        return buffer.rstrip.chomp("\0")
      end
    end
  end
end

Version data entries

58 entries across 54 versions & 6 rubygems

Version Path
vagrant-unbundled-2.3.6.0 lib/vagrant/util/windows_path.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.3.3.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.3.2.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.19.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.18.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.16.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.14.0 lib/vagrant/util/windows_path.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.10.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.9.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.8.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.7.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.6.2 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.6.1 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.6.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.5.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.4.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.3.0 lib/vagrant/util/windows_path.rb
vagrant-unbundled-2.2.2.0 lib/vagrant/util/windows_path.rb