Ensure the file exists, create if it doesn't
(file_path, default_content="")
| 14 | |
| 15 | @staticmethod |
| 16 | def ensure_file(file_path, default_content=""): |
| 17 | """Ensure the file exists, create if it doesn't""" |
| 18 | path = Path(file_path) |
| 19 | if not path.parent.exists(): |
| 20 | FileSystemManager.ensure_dir(path.parent) |
| 21 | if not path.exists(): |
| 22 | with open(path, "w") as f: |
| 23 | f.write(default_content) |
| 24 | return path |
| 25 | |
| 26 | |
| 27 | # Get the directory where the script is located |