snimacbin.cpp

来自「pc loader for 8051 based microcomputers」· C++ 代码 · 共 54 行

CPP
54
字号
// SnimacBin.cpp: implementation of the CSnimacBin class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SnimacBin.h"

#include "Win32File.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSnimacBin::CSnimacBin(const std::string& nazivFajla)
: CSnimacFajl(nazivFajla)
{
}

CSnimacBin::CSnimacBin(CFile* pFajl)
: CSnimacFajl(pFajl)
{
}

CSnimacBin::~CSnimacBin()
{
}

void CSnimacBin::SnimiSledeciBajt(PRG::tBajt bajt, PRG::tAdresa adresa)
{
    std::string opis;
    if (!ProveriFajlPtr(opis)) throw CSnimacException(opis);

    const int BROJ_BAJTOVA = 1; // upisujem po jedan bajt
    BYTE buffer[BROJ_BAJTOVA];  // bafer za upis
    try {
        buffer[0] = bajt;
        pFajl_m->Write(buffer, sizeof(buffer));
    }
    catch (CFileException* e) {
        std::string tekstGreske = CWin32File::ExceptionToTxt(*e, "CFileException");
        e->Delete();
        throw CSnimacException(tekstGreske);
    }
    catch (...) {
        throw CSnimacException("error writing file");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?