RDI/src/RDat.cpp

51 lines
830 B
C++

/**
* @file RDat.cpp
* @date 15/09/2022
* @author JackCarterSmith
* @copyright GPL-v3.0
* @brief Rogue Dat file class interface.
*
*/
#include <iostream>
#include <fstream>
#include "RDat.h"
using namespace std;
namespace RDI {
RDat::RDat( string fPath ) {
string datFile, hdrFile;
fstream rdf;
streampos size;
datFile = fPath + "/DATA.DAT";
hdrFile = fPath + "/DATA.HDR";
rdf.open(datFile, ios::in | ios::binary);
if (rdf.is_open()) {
size = rdf.tellg();
rDatPtr = new char[size];
rdf.seekg(0, ios::beg);
rdf.read(rDatPtr, size);
rdf.close();
}
rdf.open(hdrFile, ios::in | ios::binary);
if (rdf.is_open()) {
size = rdf.tellg();
rDatPtr = new char[size];
rdf.seekg(0, ios::beg);
rdf.read(rDatPtr, size);
rdf.close();
}
}
RDat::~RDat() {
delete rDatPtr;
}
} /* namespace RDI */