def get_read_handle(filename):
if os.path.isdir(filename):
dwFlagsAndAttributes = win32file.FILE_FLAG_BACKUP_SEMANTICS
else:
dwFlagsAndAttributes = 0
# CreateFile(fileName, desiredAccess, shareMode, attributes,
# CreationDisposition, flagsAndAttributes, hTemplateFile)
try:
handle = win32file.CreateFileW(filename, # with 'W' accepts unicode
win32file.GENERIC_READ, win32file.FILE_SHARE_READ, None,
win32file.OPEN_EXISTING, dwFlagsAndAttributes, None)
return handle
except Exception as e:
raise PygcamException("get_read_handle(%s) failed: %s" % (filename, e))
评论列表
文章目录