mirror of
https://github.com/AxioDL/nod.git
synced 2025-07-04 04:06:09 +00:00
Add max-size check conditional
This commit is contained in:
parent
26af179ee8
commit
4adfa71c2f
@ -68,9 +68,12 @@ public:
|
||||
fclose(fp);
|
||||
}
|
||||
uint64_t write(const void* buf, uint64_t length)
|
||||
{
|
||||
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);
|
||||
}
|
||||
return fwrite(buf, 1, length, fp);
|
||||
}
|
||||
uint64_t copyFromDisc(IPartReadStream& discio, uint64_t length)
|
||||
|
@ -71,12 +71,15 @@ public:
|
||||
CloseHandle(fp);
|
||||
}
|
||||
uint64_t write(const void* buf, uint64_t length)
|
||||
{
|
||||
if (m_maxWriteSize >= 0)
|
||||
{
|
||||
LARGE_INTEGER li = {};
|
||||
LARGE_INTEGER res;
|
||||
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;
|
||||
WriteFile(fp, buf, length, &ret, nullptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user