//
// Created by Vicente Ferrari Smith on 13.02.26.
//

#include "misc.h"
#include <fstream>

std::string read_entire_file(const std::string &path) {
    std::ifstream f(path, std::ios::binary | std::ios::ate);

    if (!f.is_open()) return {};

    const std::streamsize size = f.tellg();
    std::string buffer;
    buffer.resize(static_cast<size_t>(size)); // Pre-allocate the string memory

    f.seekg(0);
    f.read(&buffer[0], size); // Read directly into the string buffer

    return buffer;
}
