Sha256: d123fc474656592d52d81cdfe2279ccf5215fc53a860e6a1263f350cff64e72d
Contents?: true
Size: 1.01 KB
Versions: 60
Compression:
Stored size: 1.01 KB
Contents
require 'win32/dir/constants' require 'win32/dir/functions' require 'win32/dir/structs' class DirMonkeyPatched include ::Dir::Structs include ::Dir::Constants extend ::Dir::Functions path = nil key = :PERSONAL value = 0x0005 buf = 0.chr * 1024 buf.encode!(Encoding::UTF_16LE) if SHGetFolderPathW(0, value, 0, 0, buf) == 0 # Current path path = buf.strip elsif SHGetFolderPathW(0, value, 0, 1, buf) == 0 # Default path path = buf.strip else FFI::MemoryPointer.new(:long) do |ptr| if SHGetFolderLocation(0, value, 0, 0, ptr) == 0 SHFILEINFO.new do |info| flags = SHGFI_DISPLAYNAME | SHGFI_PIDL if SHGetFileInfo(ptr.read_long, 0, info, info.size, flags) != 0 path = info[:szDisplayName].to_s end end end end end if path.nil? begin Dir.const_set(key, ''.encode(Encoding.default_external)) rescue Encoding::UndefinedConversionError Dir.const_set(key, ''.encode(Encoding::UTF_8)) end end end
Version data entries
60 entries across 60 versions & 1 rubygems