def open_file(filepath, flags=FILE_FLAG_OPEN_REPARSE_POINT, autoclose=False):
	""" Open file for read & write, acquiring the SE_BACKUP & SE_RESTORE privileges. """
	obtain_privileges([ SE_BACKUP_NAME, SE_RESTORE_NAME ])
	if (flags & FILE_FLAG_BACKUP_SEMANTICS) != FILE_FLAG_BACKUP_SEMANTICS:
		flags |= FILE_FLAG_BACKUP_SEMANTICS
	hFile = CreateFile(filepath, GENERIC_RW, FILE_SHARE_ALL, NULL, OPEN_EXISTING, flags, HANDLE.NULL)
	if not hFile: raise WinError()
	if autoclose: hFile.autoclose = True
	return hFile
 Open file for read & write, acquiring the SE_BACKUP & SE_RESTORE privileges. 
recipes/Python/578849_Reimplementatirmtree_supporting_Windows_reparse_/recipe-578849.py