29 std::span<SectorBuffer> buffers,
size_t startSector)
const
31 auto last = startSector + buffers.size() - 1;
43 std::span{buffers[0].raw.data(),
44 buffers.size_bytes()});
51 std::span<SectorBuffer> buffers,
size_t startSector)
55 for (
auto [i, buf] :
enumerate(buffers)) {
76 writeSectorImpl(sector, buf);
84 std::span<const SectorBuffer> buffers,
size_t startSector)
88 for (
auto [i, buf] :
enumerate(buffers)) {
96 return getNbSectorsImpl();
101 patch = std::make_unique<IPSPatch>(std::move(patchFile), std::move(patch));
106 return patch->getFilenames();
111 return !patch->isEmptyPatch();
117 if (sha1cache.
empty()) {
129 std::array<SectorBuffer, 32> buf;
132 while (sector < total) {
133 auto chunk = std::min(buf.size(), total - sector);
134 auto sub =
subspan(buf, 0, chunk);
136 sha1.
update({sub[0].raw.data(), sub.size_bytes()});
150 return forcedWriteProtect || isWriteProtectedImpl();
156 forcedWriteProtect =
true;
This class represents a filename.
Helper class to perform a sha1 calculation.
Sha1Sum digest()
Get the final hash.
void update(std::span< const uint8_t > data)
Incrementally calculate the hash value.
bool isWriteProtected() const
virtual bool isDummyDisk() const
void writeSectors(std::span< const SectorBuffer > buffers, size_t startSector)
void readSectors(std::span< SectorBuffer > buffers, size_t startSector) const
virtual Sha1Sum getSha1SumImpl(FilePool &filePool)
Sha1Sum getSha1Sum(FilePool &filePool)
Calculate SHA1 of the content of this disk.
virtual void checkCaches()
size_t getNbSectors() const
virtual void flushCaches()
virtual void readSectorsImpl(std::span< SectorBuffer > buffers, size_t startSector)
std::vector< Filename > getPatches() const
void applyPatch(Filename patchFile)
void readSector(size_t sector, SectorBuffer &buf) const
void writeSector(size_t sector, const SectorBuffer &buf)
virtual void readSectorImpl(size_t sector, SectorBuffer &buf)
void setPeekMode(bool peek)
This class represents the result of a sha1 calculation (a 160-bit value).
constexpr auto enumerate(Iterable &&iterable)
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta....
This file implemented 3 utility functions:
constexpr auto subspan(Range &&range, size_t offset, size_t count=std::dynamic_extent)