Add realpath for Windows

Fixes #4446
Add 2nd try if the 1st buffer is too small.
Merge pull request #4573 from karbarcca/patch-3

Add realpath for Windows