mirror of
https://github.com/AxioDL/nod.git
synced 2025-12-08 13:14:59 +00:00
General: Make use of override where applicable
Makes it explicit where functions are being overridden in derived classes/structs.
This commit is contained in:
@@ -13,7 +13,7 @@ class FileIOFILE : public IFileIO {
|
||||
public:
|
||||
FileIOFILE(SystemStringView path, int64_t maxWriteSize) : m_path(path), m_maxWriteSize(maxWriteSize) {}
|
||||
|
||||
bool exists() {
|
||||
bool exists() override {
|
||||
FILE* fp = Fopen(m_path.c_str(), _SYS_STR("rb"));
|
||||
if (!fp)
|
||||
return false;
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t size() {
|
||||
uint64_t size() override {
|
||||
FILE* fp = Fopen(m_path.c_str(), _SYS_STR("rb"));
|
||||
if (!fp)
|
||||
return 0;
|
||||
@@ -56,8 +56,8 @@ public:
|
||||
LogModule.report(logvisor::Error, fmt(_SYS_STR("unable to open '{}' for writing")), path);
|
||||
err = true;
|
||||
}
|
||||
~WriteStream() { fclose(fp); }
|
||||
uint64_t write(const void* buf, uint64_t length) {
|
||||
~WriteStream() override { fclose(fp); }
|
||||
uint64_t write(const void* buf, uint64_t length) override {
|
||||
if (m_maxWriteSize >= 0) {
|
||||
if (FTell(fp) + length > m_maxWriteSize) {
|
||||
LogModule.report(logvisor::Error, fmt(_SYS_STR("write operation exceeds file's {}-byte limit")),
|
||||
@@ -68,14 +68,14 @@ public:
|
||||
return fwrite(buf, 1, length, fp);
|
||||
}
|
||||
};
|
||||
std::unique_ptr<IWriteStream> beginWriteStream() const {
|
||||
std::unique_ptr<IWriteStream> beginWriteStream() const override {
|
||||
bool Err = false;
|
||||
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, m_maxWriteSize, Err));
|
||||
if (Err)
|
||||
return {};
|
||||
return ret;
|
||||
}
|
||||
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const {
|
||||
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const override {
|
||||
bool Err = false;
|
||||
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, offset, m_maxWriteSize, Err));
|
||||
if (Err)
|
||||
@@ -97,11 +97,11 @@ public:
|
||||
return;
|
||||
FSeek(fp, offset, SEEK_SET);
|
||||
}
|
||||
~ReadStream() { fclose(fp); }
|
||||
void seek(int64_t offset, int whence) { FSeek(fp, offset, whence); }
|
||||
uint64_t position() const { return FTell(fp); }
|
||||
uint64_t read(void* buf, uint64_t length) { return fread(buf, 1, length, fp); }
|
||||
uint64_t copyToDisc(IPartWriteStream& discio, uint64_t length) {
|
||||
~ReadStream() override { fclose(fp); }
|
||||
void seek(int64_t offset, int whence) override { FSeek(fp, offset, whence); }
|
||||
uint64_t position() const override { return FTell(fp); }
|
||||
uint64_t read(void* buf, uint64_t length) override { return fread(buf, 1, length, fp); }
|
||||
uint64_t copyToDisc(IPartWriteStream& discio, uint64_t length) override {
|
||||
uint64_t written = 0;
|
||||
uint8_t buf[0x7c00];
|
||||
while (length) {
|
||||
@@ -120,14 +120,14 @@ public:
|
||||
return written;
|
||||
}
|
||||
};
|
||||
std::unique_ptr<IReadStream> beginReadStream() const {
|
||||
std::unique_ptr<IReadStream> beginReadStream() const override {
|
||||
bool Err = false;
|
||||
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, Err));
|
||||
if (Err)
|
||||
return {};
|
||||
return ret;
|
||||
}
|
||||
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const {
|
||||
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const override {
|
||||
bool Err = false;
|
||||
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, offset, Err));
|
||||
if (Err)
|
||||
|
||||
Reference in New Issue
Block a user