MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / files_under

Function files_under

tests/harness/native_support.py:43–56  ·  view source on GitHub ↗

Compare file artifacts byte-for-byte, including modes and link targets.

(path)

Source from the content-addressed store, hash-verified

41
42
43def files_under(path):
44 """Compare file artifacts byte-for-byte, including modes and link targets."""
45 result = {}
46 if path.exists():
47 for directory, dirs, files in os.walk(path, followlinks=False):
48 dirs[:] = [d for d in dirs if d not in ('.atomic', '.git')]
49 for name in files + [d for d in dirs if Path(directory, d).is_symlink()]:
50 p = Path(directory, name)
51 mode = p.lstat().st_mode
52 result[str(p.relative_to(path))] = (
53 stat.S_IFMT(mode), stat.S_IMODE(mode),
54 os.readlink(p) if p.is_symlink() else hashlib.sha256(p.read_bytes()).hexdigest())
55 dirs[:] = [d for d in dirs if not Path(directory, d).is_symlink()]
56 return result

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls 2

existsMethod · 0.45
walkMethod · 0.45

Tested by 2

mainFunction · 0.72
mainFunction · 0.72