/* * ═══════════════════════════════════════════════════════════════════════════════════ * FILEMANAGER.HPP - SD Card and File Operations Manager * ═══════════════════════════════════════════════════════════════════════════════════ * * 📁 THE FILE SYSTEM ORCHESTRATOR OF VESPER 📁 * * This class provides a clean, robust interface for all file operations * including melody file management, configuration persistence, and * comprehensive error handling with automatic recovery. * * 📋 VERSION: 2.0 (Enhanced file management) * 📅 DATE: 2025 * 👨‍💻 AUTHOR: Advanced Bell Systems * ═══════════════════════════════════════════════════════════════════════════════════ */ #ifndef FILEMANAGER_HPP #define FILEMANAGER_HPP #include #include #include #include #include #include #include #include "../Logging/Logging.hpp" #include "../ConfigManager/ConfigManager.hpp" class FileManager { private: ConfigManager* configManager; public: // Constructor FileManager(ConfigManager* config); // Core file operations bool downloadFile(const String& url, const String& directory, const String& filename); bool addMelody(JsonVariant doc); // Download melody file from JSON data String listFilesAsJson(const char* dirPath); // File utilities bool fileExists(const String& filePath); bool deleteFile(const String& filePath); bool createDirectory(const String& dirPath); size_t getFileSize(const String& filePath); // Generic read/write for JSON data bool writeJsonFile(const String& filePath, JsonDocument& doc); bool readJsonFile(const String& filePath, JsonDocument& doc); // ═══════════════════════════════════════════════════════════════════════════════ // HEALTH CHECK METHOD // ═══════════════════════════════════════════════════════════════════════════════ /** @brief Check if FileManager is in healthy state */ bool isHealthy() const; private: // Helper functions bool initializeSD(); bool ensureDirectoryExists(const String& dirPath); }; #endif