Fix behavior of os.getFileInfo() for symbolic links.

The calls to lstat() and stat() were switched. As a result,
links weren't followed for followLink == true and links were
followed for followLink == false.
This commit is contained in:
Reimer Behrends
2015-05-13 12:26:34 +02:00
parent 0b184f2584
commit 28dd0407bb

View File

@@ -2033,10 +2033,10 @@ proc getFileInfo*(path: string, followSymlink = true): FileInfo =
else:
var rawInfo: TStat
if followSymlink:
if lstat(path, rawInfo) < 0'i32:
if stat(path, rawInfo) < 0'i32:
raiseOSError(osLastError())
else:
if stat(path, rawInfo) < 0'i32:
if lstat(path, rawInfo) < 0'i32:
raiseOSError(osLastError())
rawToFormalFileInfo(rawInfo, result)