This commit is contained in:
2026-08-29 01:50:09 +08:00
parent 28e91366d6
commit 846d6c03e0
11 changed files with 490 additions and 15 deletions

View File

@@ -0,0 +1,18 @@
"""简单的文件锁标记工具。"""
from __future__ import annotations
from os import PathLike
from pathlib import Path
def is_lock(file_path: str | PathLike[str]) -> bool:
"""判断指定的锁文件是否存在。"""
return Path(file_path).is_file()
def write_lockfile(file_path: str | PathLike[str]) -> None:
"""创建锁文件;父目录不存在时自动创建。"""
path = Path(file_path)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("LOCK", encoding="utf-8")