[Win32utils-devel] File.readlink for Vista?

Heesob Park phasis at gmail.com
Wed Nov 12 07:47:16 EST 2008


Hi,

2008/11/12 Daniel Berger <djberg96 at gmail.com>:
> Hi,
>
> I've implemented File.symlink and File.symlink? in the win32-file library,
> but I'm not sure how to implement File.readlink. I searched Google for a
> while but found nothing.
>
> Any suggestions?
>
Here is File.readlink implementation

def readlink(file)
  hFile = CreateFile(file,
                         GENERIC_READ,
                         FILE_SHARE_READ,
                         nil,
                         OPEN_EXISTING,
                         FILE_ATTRIBUTE_NORMAL,
                         nil)
  path = 0.chr * 256
  GetFinalPathNameByHandle(hFile,path,256,0)
  CloseHandle(hFile)
  path.strip[4..-1]  # get rid of prepending "\\?\"
end

Regards,

Park Heesob


More information about the win32utils-devel mailing list