#pragma once

#include "FileFormats.h"

#include <filesystem>
#include <string>
#include <fstream>
#include <memory>
#include <vector>

using Path = std::filesystem::path;

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

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();

    std::vector<std::string> readLines();

    static std::string getBaseFilename(const Path& path);

    bool PathExists() const;

    void SetAccessMode(AccessMode mode);

    void Open(bool asBinary = false);

    void Close();


private:

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

};
