#ifndef BIWAK_FLASH_FILE_H
#define BIWAK_FLASH_FILE_H
//----------------------------------------------------------------------------
///
/// \brief  Faked flash in file
///
///
/// \date   20221125
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//----------------------------------------------------------------------------


//---Includes-----------------------------------------------------------------


//---Own------------------------------

#include <biwak/flash.h>
#include <QFile>

//---Declaration--------------------------------------------------------------


class CFlashFile
        :public CFlash
{
      QFile m_file;

   public:
      CFlashFile(const QString& fileName, bool needsToExist = true);
      CFlashFile(const char *fileName , bool needsToExist = true);
      CFlashFile(const QString& fileName, int size);
      ~CFlashFile();

      virtual int erasePage(address_t addr, int count=1) override;
      int eraseAll();
      /*
      virtual int erasePageSize() const override
      {
         return(m_eraseSize);
      }
      */
      virtual int readData(address_t addr, void *data, int size) override;
      virtual int writeData(address_t addr, const void *data, int size) override;
      void close();
      
      void eraseChip()
      {
         return;
      }
      bool waitForReady()
      {
         return(true);
      }
      // Compatibility with CFlashSpi class
      int readJId()
      {
         return( 0x1122 );
      }
      // Compatibility with CFlashSpi class
      void wakeUp()
      {
         return;
      }
      QString fileName()
      {
         return( m_file.fileName() );
      }
      void rename(const QString& newName)
      {
         m_file.rename(newName);
      }
};


//---fin----------------------------------------------------------------------
#endif // ? ! BIWAK_FLASH_FILE_H
