mirror of https://github.com/AxioDL/nod.git
General: Make use of override where applicable
Makes it explicit where functions are being overridden in derived classes/structs.
This commit is contained in:
parent
ac6f2a1ed2
commit
2171388b9d
|
@ -11,7 +11,7 @@ class DiscGCN : public DiscBase {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DiscGCN(std::unique_ptr<IDiscIO>&& dio, bool& err);
|
DiscGCN(std::unique_ptr<IDiscIO>&& dio, bool& err);
|
||||||
bool extractDiscHeaderFiles(SystemStringView path, const ExtractionContext& ctx) const;
|
bool extractDiscHeaderFiles(SystemStringView path, const ExtractionContext& ctx) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiscBuilderGCN : public DiscBuilderBase {
|
class DiscBuilderGCN : public DiscBuilderBase {
|
||||||
|
|
|
@ -9,7 +9,7 @@ class DiscWii : public DiscBase {
|
||||||
public:
|
public:
|
||||||
DiscWii(std::unique_ptr<IDiscIO>&& dio, bool& err);
|
DiscWii(std::unique_ptr<IDiscIO>&& dio, bool& err);
|
||||||
DiscBuilderWii makeMergeBuilder(SystemStringView outPath, bool dualLayer, FProgress progressCB);
|
DiscBuilderWii makeMergeBuilder(SystemStringView outPath, bool dualLayer, FProgress progressCB);
|
||||||
bool extractDiscHeaderFiles(SystemStringView path, const ExtractionContext& ctx) const;
|
bool extractDiscHeaderFiles(SystemStringView path, const ExtractionContext& ctx) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiscBuilderWii : public DiscBuilderBase {
|
class DiscBuilderWii : public DiscBuilderBase {
|
||||||
|
|
|
@ -32,11 +32,11 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IPartReadStream : IReadStream {
|
struct IPartReadStream : IReadStream {
|
||||||
virtual ~IPartReadStream() = default;
|
~IPartReadStream() override = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IPartWriteStream : IWriteStream {
|
struct IPartWriteStream : IWriteStream {
|
||||||
virtual ~IPartWriteStream() = default;
|
~IPartWriteStream() override = default;
|
||||||
virtual void close() = 0;
|
virtual void close() = 0;
|
||||||
virtual uint64_t position() const = 0;
|
virtual uint64_t position() const = 0;
|
||||||
};
|
};
|
||||||
|
@ -49,15 +49,15 @@ class AthenaPartReadStream : public athena::io::IStreamReader {
|
||||||
public:
|
public:
|
||||||
AthenaPartReadStream(std::unique_ptr<IPartReadStream>&& rs) : m_rs(std::move(rs)) {}
|
AthenaPartReadStream(std::unique_ptr<IPartReadStream>&& rs) : m_rs(std::move(rs)) {}
|
||||||
|
|
||||||
inline void seek(atInt64 off, athena::SeekOrigin origin) {
|
void seek(atInt64 off, athena::SeekOrigin origin) override {
|
||||||
if (origin == athena::Begin)
|
if (origin == athena::Begin)
|
||||||
m_rs->seek(off, SEEK_SET);
|
m_rs->seek(off, SEEK_SET);
|
||||||
else if (origin == athena::Current)
|
else if (origin == athena::Current)
|
||||||
m_rs->seek(off, SEEK_CUR);
|
m_rs->seek(off, SEEK_CUR);
|
||||||
}
|
}
|
||||||
inline atUint64 position() const { return m_rs->position(); }
|
atUint64 position() const override { return m_rs->position(); }
|
||||||
inline atUint64 length() const { return 0; }
|
atUint64 length() const override { return 0; }
|
||||||
inline atUint64 readUBytesToBuf(void* buf, atUint64 sz) {
|
atUint64 readUBytesToBuf(void* buf, atUint64 sz) override {
|
||||||
m_rs->read(buf, sz);
|
m_rs->read(buf, sz);
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
m_dio->read(m_buf, BUFFER_SZ);
|
m_dio->read(m_buf, BUFFER_SZ);
|
||||||
m_curBlock = block;
|
m_curBlock = block;
|
||||||
}
|
}
|
||||||
void seek(int64_t offset, int whence) {
|
void seek(int64_t offset, int whence) override {
|
||||||
if (whence == SEEK_SET)
|
if (whence == SEEK_SET)
|
||||||
m_offset = offset;
|
m_offset = offset;
|
||||||
else if (whence == SEEK_CUR)
|
else if (whence == SEEK_CUR)
|
||||||
|
@ -66,8 +66,8 @@ public:
|
||||||
m_curBlock = block;
|
m_curBlock = block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint64_t position() const { return m_offset; }
|
uint64_t position() const override { return m_offset; }
|
||||||
uint64_t read(void* buf, uint64_t length) {
|
uint64_t read(void* buf, uint64_t length) override {
|
||||||
size_t block = m_offset / BUFFER_SZ;
|
size_t block = m_offset / BUFFER_SZ;
|
||||||
size_t cacheOffset = m_offset % BUFFER_SZ;
|
size_t cacheOffset = m_offset % BUFFER_SZ;
|
||||||
uint64_t cacheSize;
|
uint64_t cacheSize;
|
||||||
|
@ -96,7 +96,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IPartReadStream> beginReadStream(uint64_t offset) const {
|
std::unique_ptr<IPartReadStream> beginReadStream(uint64_t offset) const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IPartReadStream>(new PartReadStream(*this, offset, Err));
|
auto ret = std::unique_ptr<IPartReadStream>(new PartReadStream(*this, offset, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
|
@ -135,9 +135,9 @@ public:
|
||||||
if (!m_fio)
|
if (!m_fio)
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
void close() { m_fio.reset(); }
|
void close() override { m_fio.reset(); }
|
||||||
uint64_t position() const { return m_offset; }
|
uint64_t position() const override { return m_offset; }
|
||||||
uint64_t write(const void* buf, uint64_t length) {
|
uint64_t write(const void* buf, uint64_t length) override {
|
||||||
uint64_t len = m_fio->write(buf, length);
|
uint64_t len = m_fio->write(buf, length);
|
||||||
m_offset += len;
|
m_offset += len;
|
||||||
return len;
|
return len;
|
||||||
|
@ -151,7 +151,7 @@ public:
|
||||||
PartitionBuilderGCN(DiscBuilderBase& parent)
|
PartitionBuilderGCN(DiscBuilderBase& parent)
|
||||||
: DiscBuilderBase::PartitionBuilderBase(parent, PartitionKind::Data, false) {}
|
: DiscBuilderBase::PartitionBuilderBase(parent, PartitionKind::Data, false) {}
|
||||||
|
|
||||||
uint64_t userAllocate(uint64_t reqSz, IPartWriteStream& ws) {
|
uint64_t userAllocate(uint64_t reqSz, IPartWriteStream& ws) override {
|
||||||
m_curUser -= reqSz;
|
m_curUser -= reqSz;
|
||||||
m_curUser &= 0xfffffffffffffff0;
|
m_curUser &= 0xfffffffffffffff0;
|
||||||
if (m_curUser < 0x30000) {
|
if (m_curUser < 0x30000) {
|
||||||
|
@ -162,9 +162,9 @@ public:
|
||||||
return m_curUser;
|
return m_curUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t packOffset(uint64_t offset) const { return offset; }
|
uint32_t packOffset(uint64_t offset) const override { return offset; }
|
||||||
|
|
||||||
std::unique_ptr<IPartWriteStream> beginWriteStream(uint64_t offset) {
|
std::unique_ptr<IPartWriteStream> beginWriteStream(uint64_t offset) override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
std::unique_ptr<IPartWriteStream> ret = std::make_unique<PartWriteStream>(*this, offset, Err);
|
std::unique_ptr<IPartWriteStream> ret = std::make_unique<PartWriteStream>(*this, offset, Err);
|
||||||
if (Err)
|
if (Err)
|
||||||
|
|
|
@ -20,12 +20,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint64_t read(void* buf, uint64_t length) { return fp->read(buf, length); }
|
uint64_t read(void* buf, uint64_t length) override { return fp->read(buf, length); }
|
||||||
uint64_t position() const { return fp->position(); }
|
uint64_t position() const override { return fp->position(); }
|
||||||
void seek(int64_t offset, int whence) { fp->seek(offset, whence); }
|
void seek(int64_t offset, int whence) override { fp->seek(offset, whence); }
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const {
|
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_fio->beginReadStream(offset), Err));
|
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_fio->beginReadStream(offset), Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
|
@ -42,10 +42,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint64_t write(const void* buf, uint64_t length) { return fp->write(buf, length); }
|
uint64_t write(const void* buf, uint64_t length) override { return fp->write(buf, length); }
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const {
|
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_fio->beginWriteStream(offset), Err));
|
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_fio->beginWriteStream(offset), Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
|
|
|
@ -232,7 +232,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint64_t read(void* buf, uint64_t length) {
|
uint64_t read(void* buf, uint64_t length) override {
|
||||||
uint8_t extra[4];
|
uint8_t extra[4];
|
||||||
uint64_t rem_offset = m_offset % 4;
|
uint64_t rem_offset = m_offset % 4;
|
||||||
if (rem_offset) {
|
if (rem_offset) {
|
||||||
|
@ -249,8 +249,8 @@ public:
|
||||||
m_offset += length;
|
m_offset += length;
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
uint64_t position() const { return m_offset; }
|
uint64_t position() const override { return m_offset; }
|
||||||
void seek(int64_t offset, int whence) {
|
void seek(int64_t offset, int whence) override {
|
||||||
if (whence == SEEK_SET)
|
if (whence == SEEK_SET)
|
||||||
m_offset = offset;
|
m_offset = offset;
|
||||||
else if (whence == SEEK_CUR)
|
else if (whence == SEEK_CUR)
|
||||||
|
@ -258,7 +258,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const {
|
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IReadStream>(new ReadStream(*this, NewFileIO(filepath)->beginReadStream(), offset, Err));
|
auto ret = std::unique_ptr<IReadStream>(new ReadStream(*this, NewFileIO(filepath)->beginReadStream(), offset, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
|
@ -266,7 +266,9 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const { return std::unique_ptr<IWriteStream>(); }
|
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const override {
|
||||||
|
return std::unique_ptr<IWriteStream>();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IDiscIO> NewDiscIOWBFS(SystemStringView path) { return std::unique_ptr<IDiscIO>(new DiscIOWBFS(path)); }
|
std::unique_ptr<IDiscIO> NewDiscIOWBFS(SystemStringView path) { return std::unique_ptr<IDiscIO>(new DiscIOWBFS(path)); }
|
||||||
|
|
|
@ -345,7 +345,7 @@ public:
|
||||||
decryptBlock();
|
decryptBlock();
|
||||||
m_curBlock = block;
|
m_curBlock = block;
|
||||||
}
|
}
|
||||||
void seek(int64_t offset, int whence) {
|
void seek(int64_t offset, int whence) override {
|
||||||
if (whence == SEEK_SET)
|
if (whence == SEEK_SET)
|
||||||
m_offset = offset;
|
m_offset = offset;
|
||||||
else if (whence == SEEK_CUR)
|
else if (whence == SEEK_CUR)
|
||||||
|
@ -359,8 +359,8 @@ public:
|
||||||
m_curBlock = block;
|
m_curBlock = block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint64_t position() const { return m_offset; }
|
uint64_t position() const override { return m_offset; }
|
||||||
uint64_t read(void* buf, uint64_t length) {
|
uint64_t read(void* buf, uint64_t length) override {
|
||||||
size_t block = m_offset / 0x7c00;
|
size_t block = m_offset / 0x7c00;
|
||||||
size_t cacheOffset = m_offset % 0x7c00;
|
size_t cacheOffset = m_offset % 0x7c00;
|
||||||
uint64_t cacheSize;
|
uint64_t cacheSize;
|
||||||
|
@ -389,7 +389,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IPartReadStream> beginReadStream(uint64_t offset) const {
|
std::unique_ptr<IPartReadStream> beginReadStream(uint64_t offset) const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IPartReadStream>(new PartReadStream(*this, m_dataOff, offset, Err));
|
auto ret = std::unique_ptr<IPartReadStream>(new PartReadStream(*this, m_dataOff, offset, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
|
@ -397,7 +397,7 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t normalizeOffset(uint64_t anOffset) const { return anOffset << 2; }
|
uint64_t normalizeOffset(uint64_t anOffset) const override { return anOffset << 2; }
|
||||||
|
|
||||||
std::unique_ptr<uint8_t[]> readPartitionHeaderBuf(size_t& szOut) const {
|
std::unique_ptr<uint8_t[]> readPartitionHeaderBuf(size_t& szOut) const {
|
||||||
{
|
{
|
||||||
|
@ -424,7 +424,7 @@ public:
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool extractCryptoFiles(SystemStringView basePath, const ExtractionContext& ctx) const {
|
bool extractCryptoFiles(SystemStringView basePath, const ExtractionContext& ctx) const override {
|
||||||
Sstat theStat;
|
Sstat theStat;
|
||||||
SystemString basePathStr(basePath);
|
SystemString basePathStr(basePath);
|
||||||
|
|
||||||
|
@ -679,8 +679,8 @@ public:
|
||||||
err = true;
|
err = true;
|
||||||
m_curGroup = group;
|
m_curGroup = group;
|
||||||
}
|
}
|
||||||
~PartWriteStream() { close(); }
|
~PartWriteStream() override { PartWriteStream::close(); }
|
||||||
void close() {
|
void close() override {
|
||||||
if (m_closed)
|
if (m_closed)
|
||||||
return;
|
return;
|
||||||
m_closed = true;
|
m_closed = true;
|
||||||
|
@ -692,8 +692,8 @@ public:
|
||||||
encryptGroup(m_parent.m_h3[m_curGroup]);
|
encryptGroup(m_parent.m_h3[m_curGroup]);
|
||||||
m_fio.reset();
|
m_fio.reset();
|
||||||
}
|
}
|
||||||
uint64_t position() const { return m_offset; }
|
uint64_t position() const override { return m_offset; }
|
||||||
uint64_t write(const void* buf, uint64_t length) {
|
uint64_t write(const void* buf, uint64_t length) override {
|
||||||
size_t group = m_offset / 0x1F0000;
|
size_t group = m_offset / 0x1F0000;
|
||||||
size_t block = (m_offset - group * 0x1F0000) / 0x7c00;
|
size_t block = (m_offset - group * 0x1F0000) / 0x7c00;
|
||||||
size_t cacheOffset = m_offset % 0x7c00;
|
size_t cacheOffset = m_offset % 0x7c00;
|
||||||
|
@ -736,7 +736,7 @@ public:
|
||||||
|
|
||||||
uint64_t getCurUserEnd() const { return m_curUser; }
|
uint64_t getCurUserEnd() const { return m_curUser; }
|
||||||
|
|
||||||
uint64_t userAllocate(uint64_t reqSz, IPartWriteStream& ws) {
|
uint64_t userAllocate(uint64_t reqSz, IPartWriteStream& ws) override {
|
||||||
reqSz = ROUND_UP_32(reqSz);
|
reqSz = ROUND_UP_32(reqSz);
|
||||||
if (m_curUser + reqSz >= 0x1FB450000) {
|
if (m_curUser + reqSz >= 0x1FB450000) {
|
||||||
LogModule.report(logvisor::Error, fmt("partition exceeds maximum single-partition capacity"));
|
LogModule.report(logvisor::Error, fmt("partition exceeds maximum single-partition capacity"));
|
||||||
|
@ -754,9 +754,9 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t packOffset(uint64_t offset) const { return uint32_t(offset >> uint64_t(2)); }
|
uint32_t packOffset(uint64_t offset) const override { return uint32_t(offset >> uint64_t(2)); }
|
||||||
|
|
||||||
std::unique_ptr<IPartWriteStream> beginWriteStream(uint64_t offset) {
|
std::unique_ptr<IPartWriteStream> beginWriteStream(uint64_t offset) override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
std::unique_ptr<IPartWriteStream> ret =
|
std::unique_ptr<IPartWriteStream> ret =
|
||||||
std::make_unique<PartWriteStream>(*this, m_baseOffset + m_userOffset, offset, Err);
|
std::make_unique<PartWriteStream>(*this, m_baseOffset + m_userOffset, offset, Err);
|
||||||
|
|
|
@ -13,7 +13,7 @@ class FileIOFILE : public IFileIO {
|
||||||
public:
|
public:
|
||||||
FileIOFILE(SystemStringView path, int64_t maxWriteSize) : m_path(path), m_maxWriteSize(maxWriteSize) {}
|
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"));
|
FILE* fp = Fopen(m_path.c_str(), _SYS_STR("rb"));
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return false;
|
return false;
|
||||||
|
@ -21,7 +21,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t size() {
|
uint64_t size() override {
|
||||||
FILE* fp = Fopen(m_path.c_str(), _SYS_STR("rb"));
|
FILE* fp = Fopen(m_path.c_str(), _SYS_STR("rb"));
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -56,8 +56,8 @@ public:
|
||||||
LogModule.report(logvisor::Error, fmt(_SYS_STR("unable to open '{}' for writing")), path);
|
LogModule.report(logvisor::Error, fmt(_SYS_STR("unable to open '{}' for writing")), path);
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
~WriteStream() { fclose(fp); }
|
~WriteStream() override { fclose(fp); }
|
||||||
uint64_t write(const void* buf, uint64_t length) {
|
uint64_t write(const void* buf, uint64_t length) override {
|
||||||
if (m_maxWriteSize >= 0) {
|
if (m_maxWriteSize >= 0) {
|
||||||
if (FTell(fp) + length > m_maxWriteSize) {
|
if (FTell(fp) + length > m_maxWriteSize) {
|
||||||
LogModule.report(logvisor::Error, fmt(_SYS_STR("write operation exceeds file's {}-byte limit")),
|
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);
|
return fwrite(buf, 1, length, fp);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::unique_ptr<IWriteStream> beginWriteStream() const {
|
std::unique_ptr<IWriteStream> beginWriteStream() const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, m_maxWriteSize, Err));
|
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, m_maxWriteSize, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
return {};
|
return {};
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const {
|
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, offset, m_maxWriteSize, Err));
|
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, offset, m_maxWriteSize, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
|
@ -97,11 +97,11 @@ public:
|
||||||
return;
|
return;
|
||||||
FSeek(fp, offset, SEEK_SET);
|
FSeek(fp, offset, SEEK_SET);
|
||||||
}
|
}
|
||||||
~ReadStream() { fclose(fp); }
|
~ReadStream() override { fclose(fp); }
|
||||||
void seek(int64_t offset, int whence) { FSeek(fp, offset, whence); }
|
void seek(int64_t offset, int whence) override { FSeek(fp, offset, whence); }
|
||||||
uint64_t position() const { return FTell(fp); }
|
uint64_t position() const override { return FTell(fp); }
|
||||||
uint64_t read(void* buf, uint64_t length) { return fread(buf, 1, length, fp); }
|
uint64_t read(void* buf, uint64_t length) override { return fread(buf, 1, length, fp); }
|
||||||
uint64_t copyToDisc(IPartWriteStream& discio, uint64_t length) {
|
uint64_t copyToDisc(IPartWriteStream& discio, uint64_t length) override {
|
||||||
uint64_t written = 0;
|
uint64_t written = 0;
|
||||||
uint8_t buf[0x7c00];
|
uint8_t buf[0x7c00];
|
||||||
while (length) {
|
while (length) {
|
||||||
|
@ -120,14 +120,14 @@ public:
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::unique_ptr<IReadStream> beginReadStream() const {
|
std::unique_ptr<IReadStream> beginReadStream() const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, Err));
|
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
return {};
|
return {};
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const {
|
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, offset, Err));
|
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, offset, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
|
|
|
@ -13,7 +13,7 @@ class FileIOWin32 : public IFileIO {
|
||||||
public:
|
public:
|
||||||
FileIOWin32(SystemStringView path, int64_t maxWriteSize) : m_path(path), m_maxWriteSize(maxWriteSize) {}
|
FileIOWin32(SystemStringView path, int64_t maxWriteSize) : m_path(path), m_maxWriteSize(maxWriteSize) {}
|
||||||
|
|
||||||
bool exists() {
|
bool exists() override {
|
||||||
#if !WINDOWS_STORE
|
#if !WINDOWS_STORE
|
||||||
HANDLE fp = CreateFileW(m_path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,
|
HANDLE fp = CreateFileW(m_path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,
|
||||||
FILE_ATTRIBUTE_NORMAL, nullptr);
|
FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||||
|
@ -26,7 +26,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t size() {
|
uint64_t size() override {
|
||||||
#if !WINDOWS_STORE
|
#if !WINDOWS_STORE
|
||||||
HANDLE fp = CreateFileW(m_path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,
|
HANDLE fp = CreateFileW(m_path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,
|
||||||
FILE_ATTRIBUTE_NORMAL, nullptr);
|
FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||||
|
@ -76,8 +76,8 @@ public:
|
||||||
lioffset.QuadPart = offset;
|
lioffset.QuadPart = offset;
|
||||||
SetFilePointerEx(fp, lioffset, nullptr, FILE_BEGIN);
|
SetFilePointerEx(fp, lioffset, nullptr, FILE_BEGIN);
|
||||||
}
|
}
|
||||||
~WriteStream() { CloseHandle(fp); }
|
~WriteStream() override { CloseHandle(fp); }
|
||||||
uint64_t write(const void* buf, uint64_t length) {
|
uint64_t write(const void* buf, uint64_t length) override {
|
||||||
if (m_maxWriteSize >= 0) {
|
if (m_maxWriteSize >= 0) {
|
||||||
LARGE_INTEGER li = {};
|
LARGE_INTEGER li = {};
|
||||||
LARGE_INTEGER res;
|
LARGE_INTEGER res;
|
||||||
|
@ -94,14 +94,14 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::unique_ptr<IWriteStream> beginWriteStream() const {
|
std::unique_ptr<IWriteStream> beginWriteStream() const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, m_maxWriteSize, Err));
|
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, m_maxWriteSize, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
return {};
|
return {};
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const {
|
std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, offset, m_maxWriteSize, Err));
|
auto ret = std::unique_ptr<IWriteStream>(new WriteStream(m_path, offset, m_maxWriteSize, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
|
@ -130,24 +130,24 @@ public:
|
||||||
lioffset.QuadPart = offset;
|
lioffset.QuadPart = offset;
|
||||||
SetFilePointerEx(fp, lioffset, nullptr, FILE_BEGIN);
|
SetFilePointerEx(fp, lioffset, nullptr, FILE_BEGIN);
|
||||||
}
|
}
|
||||||
~ReadStream() { CloseHandle(fp); }
|
~ReadStream() override { CloseHandle(fp); }
|
||||||
void seek(int64_t offset, int whence) {
|
void seek(int64_t offset, int whence) override {
|
||||||
LARGE_INTEGER li;
|
LARGE_INTEGER li;
|
||||||
li.QuadPart = offset;
|
li.QuadPart = offset;
|
||||||
SetFilePointerEx(fp, li, nullptr, whence);
|
SetFilePointerEx(fp, li, nullptr, whence);
|
||||||
}
|
}
|
||||||
uint64_t position() const {
|
uint64_t position() const override {
|
||||||
LARGE_INTEGER li = {};
|
LARGE_INTEGER li = {};
|
||||||
LARGE_INTEGER res;
|
LARGE_INTEGER res;
|
||||||
SetFilePointerEx(fp, li, &res, FILE_CURRENT);
|
SetFilePointerEx(fp, li, &res, FILE_CURRENT);
|
||||||
return res.QuadPart;
|
return res.QuadPart;
|
||||||
}
|
}
|
||||||
uint64_t read(void* buf, uint64_t length) {
|
uint64_t read(void* buf, uint64_t length) override {
|
||||||
DWORD ret = 0;
|
DWORD ret = 0;
|
||||||
ReadFile(fp, buf, length, &ret, nullptr);
|
ReadFile(fp, buf, length, &ret, nullptr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
uint64_t copyToDisc(IPartWriteStream& discio, uint64_t length) {
|
uint64_t copyToDisc(IPartWriteStream& discio, uint64_t length) override {
|
||||||
uint64_t written = 0;
|
uint64_t written = 0;
|
||||||
uint8_t buf[0x7c00];
|
uint8_t buf[0x7c00];
|
||||||
while (length) {
|
while (length) {
|
||||||
|
@ -166,14 +166,14 @@ public:
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::unique_ptr<IReadStream> beginReadStream() const {
|
std::unique_ptr<IReadStream> beginReadStream() const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, Err));
|
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
return {};
|
return {};
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const {
|
std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const override {
|
||||||
bool Err = false;
|
bool Err = false;
|
||||||
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, offset, Err));
|
auto ret = std::unique_ptr<IReadStream>(new ReadStream(m_path, offset, Err));
|
||||||
if (Err)
|
if (Err)
|
||||||
|
|
|
@ -173,9 +173,9 @@ protected:
|
||||||
void _decrypt(uint8_t* buff);
|
void _decrypt(uint8_t* buff);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void encrypt(const uint8_t* iv, const uint8_t* inbuf, uint8_t* outbuf, size_t len);
|
void encrypt(const uint8_t* iv, const uint8_t* inbuf, uint8_t* outbuf, size_t len) override;
|
||||||
void decrypt(const uint8_t* iv, const uint8_t* inbuf, uint8_t* outbuf, size_t len);
|
void decrypt(const uint8_t* iv, const uint8_t* inbuf, uint8_t* outbuf, size_t len) override;
|
||||||
void setKey(const uint8_t* key);
|
void setKey(const uint8_t* key) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SoftwareAES::gkey(int nb, int nk, const uint8_t* key) {
|
void SoftwareAES::gkey(int nb, int nk, const uint8_t* key) {
|
||||||
|
|
Loading…
Reference in New Issue