#pragma once
#include "BaseFile.h"

constexpr auto bufSize = 256;

class CBKASCFile : public CBaseFile
{
		bool            m_bEof{ false };
		int             m_nInternalBlockNumber{ 0 };
		int             m_nInternalPos{ 0 };
		std::array <char, bufSize> m_pWrBuf{ 0 };
		bool            m_bFlushed{ false };

		fs::path        m_strInternalAscName;
		fs::path        m_strInternalCurrentName;
		void            MakeintenalCurrentName();
		bool            OpenInternalFile();

	public:
		CBKASCFile(const fs::path &strName);
		virtual ~CBKASCFile() override;

		virtual bool    Open(bool bWrite) override; // открытие файла, имя которого задано в конструкторе
		virtual uint32_t ReadChar() override;
		virtual bool    WriteChar(uint32_t tch) override;
		virtual bool    WriteWord(uint16_t w);
		virtual long    GetPos() const override;
		virtual int     SetPos(long pos, long mode) const override;

		virtual bool    isEOF() const override
		{
			return m_bEof;
		}

		bool            FlushInternalWrBuff();

};

namespace ITCPC
{
	void TXT2ASC(std::unique_ptr<CBaseFile> pInFile, std::unique_ptr<CBKASCFile> pOutFile);
}
