Release SyncVito 1.0.7
This commit is contained in:
1 parent
3d6ab87ce3
commit
a04db4ee96
10 files changed
+278
-28
No files matched your search
@@ -23,7 +23,22 @@ def is_file_locked(path: Path) -> bool:
|
||||
"""Prüft eine vorhandene Datei durch exklusives Öffnen ohne Schreibzugriff."""
|
||||
if not path.exists() or os.name != "nt":
|
||||
return False
|
||||
handle = ctypes.windll.kernel32.CreateFileW(
|
||||
kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
|
||||
create_file = kernel32.CreateFileW
|
||||
create_file.argtypes = [
|
||||
wintypes.LPCWSTR,
|
||||
wintypes.DWORD,
|
||||
wintypes.DWORD,
|
||||
ctypes.c_void_p,
|
||||
wintypes.DWORD,
|
||||
wintypes.DWORD,
|
||||
wintypes.HANDLE,
|
||||
]
|
||||
create_file.restype = wintypes.HANDLE
|
||||
close_handle = kernel32.CloseHandle
|
||||
close_handle.argtypes = [wintypes.HANDLE]
|
||||
close_handle.restype = wintypes.BOOL
|
||||
handle = create_file(
|
||||
str(path),
|
||||
0x80000000,
|
||||
0,
|
||||
@@ -34,8 +49,8 @@ def is_file_locked(path: Path) -> bool:
|
||||
)
|
||||
invalid_handle = ctypes.c_void_p(-1).value
|
||||
if handle == invalid_handle:
|
||||
return ctypes.get_last_error() in {5, 32, 33}
|
||||
ctypes.windll.kernel32.CloseHandle(handle)
|
||||
return ctypes.get_last_error() in {32, 33}
|
||||
close_handle(handle)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user