from pathlib import Path


class FileManager:
    def __init__(self, file_path):
        self.file_path = file_path
        # Create parent directories if they don't exist
        Path(file_path).parent.mkdir(parents=True, exist_ok=True)

    def read_file(self):
        with Path(self.file_path).open(encoding="utf-8") as file:
            return file.read()

    def write_file(self, data):
        with Path(self.file_path).open("w", encoding="utf-8") as file:
            file.write(data)
