#pragma once

#include <string>
#include <vector>
#include <memory>
#include <functional>

namespace mosis {

/**
 * Platform-agnostic interface for filesystem operations.
 * Used for app data storage, not assets.
 */
class IFilesystemInterface {
public:
    virtual ~IFilesystemInterface() = default;

    /**
     * Get the base data directory for apps.
     * Android: /data/data/com.omixlab.mosis/files/
     * Desktop: ./data/ or configurable
     */
    virtual std::string GetDataRoot() = 0;

    /**
     * Get the apps installation directory.
     * Contains installed app packages.
     */
    virtual std::string GetAppsDirectory() = 0;

    /**
     * Get app-specific data directory.
     * @param app_id Application ID (e.g., "com.example.app")
     */
    virtual std::string GetAppDataDirectory(const std::string& app_id) = 0;

    /**
     * Get app-specific cache directory.
     */
    virtual std::string GetAppCacheDirectory(const std::string& app_id) = 0;

    /**
     * Create directory if it doesn't exist.
     * @return true on success
     */
    virtual bool CreateDirectory(const std::string& path) = 0;

    /**
     * Check if path exists.
     */
    virtual bool Exists(const std::string& path) = 0;

    /**
     * Check if path is a directory.
     */
    virtual bool IsDirectory(const std::string& path) = 0;

    /**
     * Remove file or directory.
     * @param recursive If true, remove directory contents
     */
    virtual bool Remove(const std::string& path, bool recursive = false) = 0;

    /**
     * Read file contents.
     */
    virtual std::vector<uint8_t> ReadFile(const std::string& path) = 0;

    /**
     * Write file contents.
     */
    virtual bool WriteFile(const std::string& path, const std::vector<uint8_t>& data) = 0;

    /**
     * List directory contents.
     */
    virtual std::vector<std::string> ListDirectory(const std::string& path) = 0;

    /**
     * Get file size.
     * @return Size in bytes, or -1 if not found
     */
    virtual int64_t GetFileSize(const std::string& path) = 0;

    /**
     * Copy file.
     */
    virtual bool CopyFile(const std::string& src, const std::string& dst) = 0;

    /**
     * Move/rename file.
     */
    virtual bool MoveFile(const std::string& src, const std::string& dst) = 0;
};

using FilesystemInterfacePtr = std::shared_ptr<IFilesystemInterface>;

} // namespace mosis
