[nstool] Add checks to ensure a reader object is provided to the Process classes.

This commit is contained in:
jakcron 2018-04-25 19:36:58 +08:00
parent 167a343937
commit 3411118e26
3 changed files with 16 additions and 0 deletions

View file

@ -627,6 +627,12 @@ NpdmProcess::NpdmProcess() :
void NpdmProcess::process()
{
fnd::MemoryBlob scratch;
if (mReader == nullptr)
{
throw fnd::Exception(kModuleName, "No file reader set.");
}
scratch.alloc(mReader->size());
mReader->read(scratch.getBytes(), 0, scratch.getSize());

View file

@ -110,6 +110,11 @@ void PfsProcess::process()
{
fnd::MemoryBlob scratch;
if (mReader == nullptr)
{
throw fnd::Exception(kModuleName, "No file reader set.");
}
// open minimum header to get full header size
scratch.alloc(sizeof(nx::sPfsHeader));
mReader->read(scratch.getBytes(), mOffset, scratch.getSize());

View file

@ -193,6 +193,11 @@ void XciProcess::process()
{
fnd::MemoryBlob scratch;
if (mReader == nullptr)
{
throw fnd::Exception(kModuleName, "No file reader set.");
}
// read header page
mReader->read((byte_t*)&mHdrPage, mOffset, sizeof(nx::sXciHeaderPage));