Check if file includes the specified header.
(file_path: Path, include_path: str)
| 98 | |
| 99 | |
| 100 | def check_has_include(file_path: Path, include_path: str) -> bool: |
| 101 | """Check if file includes the specified header.""" |
| 102 | try: |
| 103 | content = file_path.read_text(encoding="utf-8", errors="ignore") |
| 104 | # Match #include "fl/stl/has_include.h" or #include <fl/stl/compiler_control.h> |
| 105 | pattern = rf'^\s*#\s*include\s+[<"].*{re.escape(include_path)}[">]' |
| 106 | return bool(re.search(pattern, content, re.MULTILINE)) |
| 107 | except KeyboardInterrupt: |
| 108 | _thread.interrupt_main() |
| 109 | raise |
| 110 | except Exception as e: |
| 111 | print(f"Warning: Could not read {file_path}: {e}", file=sys.stderr) |
| 112 | return False |
| 113 | |
| 114 | |
| 115 | def find_insertion_point(content: str) -> tuple[int, str]: |