Load a single file into memory.
(path)
| 62 | return False |
| 63 | |
| 64 | def load_file(path): |
| 65 | """Load a single file into memory.""" |
| 66 | if is_ignored(path): |
| 67 | warning(f"Ignored: {path}") |
| 68 | return f"[ERROR] File is ignored by .codeyignore: {path}" |
| 69 | |
| 70 | p = Path(path).expanduser() |
| 71 | if not p.exists(): |
| 72 | p = Path(os.getcwd()) / path |
| 73 | if not p.exists(): |
| 74 | warning(f"File not found: {path}") |
| 75 | return f"[ERROR] File not found: {path}" |
| 76 | try: |
| 77 | content = p.read_text(encoding="utf-8", errors="replace") |
| 78 | _mem.load_file(str(p), content) |
| 79 | success(f"Loaded: {p.name} ({len(content)} chars)") |
| 80 | return content |
| 81 | except Exception as e: |
| 82 | return f"[ERROR] {e}" |
| 83 | |
| 84 | def load_glob(pattern): |
| 85 | import glob |