The toRealPath method has a number of performance issues that should be fixed:
1. On Vista/newer it uses GetFinalPathNameByHandle to get the final path with all symbolic links resolved. This Win32 call requires opening the file and is slower than the fallback implementation for common case that the path does not contain any symbolic links.
2. On XP or when GetFinalPathNameByHandle fails, the implementation always checks that the root directory exists. This is expensive and not required for the case that the path has one or more name components (because the directory search to get the actual name requires that the root directory exist).
2. On XP or when GetFinalPathNameByHandle fails, the implementation always calls GetFullPathName to collapse . and .. but this is not required when . is not present.