INNER CODE UNIT · Python
cursor
i3T4AN/KADATH · kadath/engine.py:67
cursor = cursor / part
mode = cursor.lstat().st_mode
if stat.S_ISLNK(mode): raise ValueError(f"symbolic link is not admissible evidence: {relative}")
if not stat.S_ISREG(item.lstat().st_mode): raise ValueError(f"non-regular evidence file: {relative}")
flags = os.O_RDONLY | getattr(os, "O_NOFOLLOW", 0)
descriptor = os.open(item, flags)
try:
if not stat.S_ISREG(os.fstat(descriptor).st_mode): raise ValueError(f"non-regular evidence file: {relative}")
with os.fdopen(descriptor, "rb", closefd=False) as stream: return stream.read()
finally:
os.close(descriptor)
def copy_scoped_regular(root: Path, item: Path, destination: Path, maximum_bytes: int) -> tuple[int, str]:
"""Copy and hash one regular file without following links or loading it into memory."""
root = root.absolute(); item = item.absolute(); relative = item.relative_to(root)
cursor = root
for part in relative.parts: