Skip to content

Instantly share code, notes, and snippets.

@Varriount
Created January 11, 2014 16:56
Show Gist options
  • Save Varriount/8373418 to your computer and use it in GitHub Desktop.
Save Varriount/8373418 to your computer and use it in GitHub Desktop.
proc getFileInfo(path: string, followSymlinks:true): FileInfo =
## Retrieve the metadata associated with file system object pointed
## to by `path` .
when defined(Windows):
var openFlags = FILE_ATTRIBUTE_NORMAL
if followSymlinks:
openFlags = (openFlags or FILE_FLAG_OPEN_REPARSE_POINT)
var handle = createFileW(path, 0'i32, 0'i32, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
if handle != INVALID_HANDLE_VALUE:
var fileInfo = getFileInfo(handle)
discard closeHandle(handle)
else:
osError(osLastError())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment