#pragma once
#include <filesystem>
#include <string>
#include "FileFormats.h"
#include <fstream>
#include <memory>

class File
{
public:
    enum class AccessMode{
        Read,
        Write
    };

private:

    std::filesystem::path mFullPath;
    std::unique_ptr<std::ifstream> mInHandle;
    std::unique_ptr<std::ofstream> mOutHandle;
    AccessMode mAccessMode;

public:

    File(std::filesystem::path fullPath);

    std::string GetExtension() const;

    FileFormat::Format InferFormat() const;

    std::ifstream* GetInHandle() const;

    std::ofstream* GetOutHandle() const;

    void WriteText(const std::string& text);

    std::string ReadText();

    bool PathExists() const;

    void SetAccessMode(AccessMode mode);

    void Open(bool asBinary = false);

    void Close();

};
