MCPcopy Create free account
hub / github.com/FastLED/FastLED / _get_max_source_file_mtime

Function _get_max_source_file_mtime

ci/util/fingerprint.py:27–67  ·  view source on GitHub ↗

Return max mtime of any source file under root, skipping build directories. Uses os.scandir() for efficiency. Detects BOTH structural changes (file add/remove) AND content modifications (file writes), unlike get_max_dir_mtime() which only detects structural changes. Args: r

(root: Path, exts: frozenset[str] | None = None)

Source from the content-addressed store, hash-verified

25
26
27def _get_max_source_file_mtime(root: Path, exts: frozenset[str] | None = None) -> float:
28 """Return max mtime of any source file under root, skipping build directories.
29
30 Uses os.scandir() for efficiency. Detects BOTH structural changes (file
31 add/remove) AND content modifications (file writes), unlike
32 get_max_dir_mtime() which only detects structural changes.
33
34 Args:
35 root: Root directory to scan
36 exts: Set of file extensions to check (default: _CPP_SOURCE_EXTS).
37 Pass _PY_SOURCE_EXTS to scan Python files instead.
38
39 Returns 0.0 on missing root or any OS error.
40 """
41 if exts is None:
42 exts = _CPP_SOURCE_EXTS
43 max_mtime = 0.0
44 stack = [str(root)]
45 while stack:
46 current = stack.pop()
47 try:
48 with os.scandir(current) as it:
49 for entry in it:
50 try:
51 name = entry.name
52 if entry.is_dir(follow_symlinks=False):
53 if name not in _SKIP_DIR_NAMES and not any(
54 name.startswith(p) for p in _SKIP_DIR_PREFIXES
55 ):
56 stack.append(entry.path)
57 elif entry.is_file(follow_symlinks=False):
58 _, ext = os.path.splitext(name)
59 if ext.lower() in exts:
60 mtime = entry.stat(follow_symlinks=False).st_mtime
61 if mtime > max_mtime:
62 max_mtime = mtime
63 except OSError:
64 pass
65 except OSError:
66 pass
67 return max_mtime
68
69
70class FingerprintManager:

Calls 3

anyFunction · 0.85
popMethod · 0.45
appendMethod · 0.45