| 1 | import sys
|
|---|
| 2 | import ctypes
|
|---|
| 3 | from ctypes.wintypes import WIN32_FIND_DATAW as WIN32_FIND_DATA
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | _INVALID_HANDLE_VALUE = -1
|
|---|
| 7 | _FindFirstFile = ctypes.windll.kernel32.FindFirstFileW
|
|---|
| 8 | _FindNextFile = ctypes.windll.kernel32.FindNextFileW
|
|---|
| 9 | _FindClose = ctypes.windll.kernel32.FindClose
|
|---|
| 10 | _GetLastError = ctypes.windll.kernel32.GetLastError
|
|---|
| 11 | FILE_ATTRIBUTE_REPARSE_POINT = 0x0400
|
|---|
| 12 |
|
|---|
| 13 | def main():
|
|---|
| 14 | if len(sys.argv) != 2:
|
|---|
| 15 | print u"Usage: %s [target_file]" % sys.argv[0]
|
|---|
| 16 | return
|
|---|
| 17 |
|
|---|
| 18 | target = unicode(sys.argv[1], sys.getfilesystemencoding())
|
|---|
| 19 |
|
|---|
| 20 | print u"Target file is %s" % target
|
|---|
| 21 |
|
|---|
| 22 | wfd = WIN32_FIND_DATA()
|
|---|
| 23 |
|
|---|
| 24 | handle = _FindFirstFile(target, ctypes.byref(wfd))
|
|---|
| 25 |
|
|---|
| 26 | if handle != _INVALID_HANDLE_VALUE:
|
|---|
| 27 | print u"Found file: %s" % wfd.cFileName
|
|---|
| 28 | print u"Reparse point: %s" % (wfd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
|---|
| 29 | print u"Attributes: %s" % wfd.dwFileAttributes
|
|---|
| 30 | while _FindNextFile(handle, ctypes.byref(wfd)):
|
|---|
| 31 | print u"Found file: %s" % wfd.cFileName
|
|---|
| 32 | else:
|
|---|
| 33 | print u"FindFirstFile failed (%d)" % _GetLastError()
|
|---|
| 34 |
|
|---|
| 35 | _FindClose(handle)
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | if __name__ == '__main__':
|
|---|
| 39 | main()
|
|---|