mirror of https://github.com/AxioDL/nod.git
Add max-size check conditional
This commit is contained in:
parent
26af179ee8
commit
4adfa71c2f
|
@ -69,8 +69,11 @@ public:
|
||||||
}
|
}
|
||||||
uint64_t write(const void* buf, uint64_t length)
|
uint64_t write(const void* buf, uint64_t length)
|
||||||
{
|
{
|
||||||
if (FTell(fp) + length > m_maxWriteSize)
|
if (m_maxWriteSize >= 0)
|
||||||
LogModule.report(LogVisor::FatalError, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
|
{
|
||||||
|
if (FTell(fp) + length > m_maxWriteSize)
|
||||||
|
LogModule.report(LogVisor::FatalError, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
|
||||||
|
}
|
||||||
return fwrite(buf, 1, length, fp);
|
return fwrite(buf, 1, length, fp);
|
||||||
}
|
}
|
||||||
uint64_t copyFromDisc(IPartReadStream& discio, uint64_t length)
|
uint64_t copyFromDisc(IPartReadStream& discio, uint64_t length)
|
||||||
|
|
|
@ -72,11 +72,14 @@ public:
|
||||||
}
|
}
|
||||||
uint64_t write(const void* buf, uint64_t length)
|
uint64_t write(const void* buf, uint64_t length)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER li = {};
|
if (m_maxWriteSize >= 0)
|
||||||
LARGE_INTEGER res;
|
{
|
||||||
SetFilePointerEx(fp, li, &res, FILE_CURRENT);
|
LARGE_INTEGER li = {};
|
||||||
if (res.QuadPart + int64_t(length) > m_maxWriteSize)
|
LARGE_INTEGER res;
|
||||||
LogModule.report(LogVisor::FatalError, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
|
SetFilePointerEx(fp, li, &res, FILE_CURRENT);
|
||||||
|
if (res.QuadPart + int64_t(length) > m_maxWriteSize)
|
||||||
|
LogModule.report(LogVisor::FatalError, _S("write operation exceeds file's %" PRIi64 "-byte limit"), m_maxWriteSize);
|
||||||
|
}
|
||||||
|
|
||||||
DWORD ret = 0;
|
DWORD ret = 0;
|
||||||
WriteFile(fp, buf, length, &ret, nullptr);
|
WriteFile(fp, buf, length, &ret, nullptr);
|
||||||
|
|
Loading…
Reference in New Issue