Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ntfsutils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

MAX_PATH = 260

INVALID_HANDLE_VALUE = -1
INVALID_HANDLE_VALUE = HANDLE(-1).value

class FILETIME(ctypes.Structure):
_fields_ = [("dwLowDateTime", DWORD),
Expand Down
7 changes: 5 additions & 2 deletions ntfsutils/junction.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ def unparsed_unconvert(path):
return path

def isjunction(path):
if not os.path.exists(path) or not fs.junctions_supported(path):
if not fs.junctions_supported(path):
return False

attrs = GetFileAttributes(path)
if attrs == DWORD(-1).value:
return False

return bool((attrs & fs.FILE_ATTRIBUTE_DIRECTORY) and
(attrs & fs.FILE_ATTRIBUTE_REPARSE_POINT))

Expand Down Expand Up @@ -157,7 +160,7 @@ def readlink(path):
if not isjunction(path):
raise Exception("%s does not exist or is not a junction" % path)

hlink = CreateFile(path, fs.GENERIC_READ, fs.FILE_SHARE_READ, None,
hlink = CreateFile(path, 0, fs.FILE_SHARE_READ, None,
fs.OPEN_EXISTING,
fs.FILE_FLAG_OPEN_REPARSE_POINT | fs.FILE_FLAG_BACKUP_SEMANTICS,
None)
Expand Down