Humungous refactor

This commit is contained in:
Jack Andersen
2016-03-04 13:04:30 -10:00
parent 7320b76ff4
commit 556a5868bb
28 changed files with 191 additions and 192 deletions

View File

@@ -1,10 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "NOD/Util.hpp"
#include "NOD/IFileIO.hpp"
#include "nod/Util.hpp"
#include "nod/IFileIO.hpp"
namespace NOD
namespace nod
{
class FileIOFILE : public IFileIO
@@ -46,7 +46,7 @@ public:
{
fp = fopen(path.c_str(), "wb");
if (!fp)
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for writing"), path.c_str());
LogModule.report(logvisor::Fatal, _S("unable to open '%s' for writing"), path.c_str());
}
WriteStream(const SystemString& path, uint64_t offset, int64_t maxWriteSize)
: m_maxWriteSize(maxWriteSize)
@@ -61,7 +61,7 @@ public:
FSeek(fp, offset, SEEK_SET);
return;
FailLoc:
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for writing"), path.c_str());
LogModule.report(logvisor::Fatal, _S("unable to open '%s' for writing"), path.c_str());
}
~WriteStream()
{
@@ -72,7 +72,7 @@ public:
if (m_maxWriteSize >= 0)
{
if (FTell(fp) + length > m_maxWriteSize)
LogModule.report(LogVisor::FatalError, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
LogModule.report(logvisor::Fatal, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
}
return fwrite(buf, 1, length, fp);
}
@@ -82,16 +82,16 @@ public:
uint8_t buf[0x7c00];
while (length)
{
uint64_t thisSz = NOD::min(uint64_t(0x7c00), length);
uint64_t thisSz = nod::min(uint64_t(0x7c00), length);
uint64_t readSz = discio.read(buf, thisSz);
if (thisSz != readSz)
{
LogModule.report(LogVisor::FatalError, "unable to read enough from disc");
LogModule.report(logvisor::Fatal, "unable to read enough from disc");
return read;
}
if (write(buf, readSz) != readSz)
{
LogModule.report(LogVisor::FatalError, "unable to write in file");
LogModule.report(logvisor::Fatal, "unable to write in file");
return read;
}
length -= thisSz;
@@ -116,7 +116,7 @@ public:
{
fp = fopen(path.c_str(), "rb");
if (!fp)
LogModule.report(LogVisor::FatalError, _S("unable to open '%s' for reading"), path.c_str());
LogModule.report(logvisor::Fatal, _S("unable to open '%s' for reading"), path.c_str());
}
ReadStream(const SystemString& path, uint64_t offset)
: ReadStream(path)
@@ -145,15 +145,15 @@ public:
uint8_t buf[0x7c00];
while (length)
{
uint64_t thisSz = NOD::min(uint64_t(0x7c00), length);
uint64_t thisSz = nod::min(uint64_t(0x7c00), length);
if (read(buf, thisSz) != thisSz)
{
LogModule.report(LogVisor::FatalError, "unable to read enough from file");
LogModule.report(logvisor::Fatal, "unable to read enough from file");
return written;
}
if (discio.write(buf, thisSz) != thisSz)
{
LogModule.report(LogVisor::FatalError, "unable to write enough to disc");
LogModule.report(logvisor::Fatal, "unable to write enough to disc");
return written;
}
length -= thisSz;