27 std::span<SectorBuffer> buffers,
size_t startSector)
29 auto last = startSector + buffers.size() - 1;
41 std::span{buffers[0].raw.data(),
42 buffers.size_bytes()});
49 std::span<SectorBuffer> buffers,
size_t startSector)
53 for (
auto [i, buf] :
enumerate(buffers)) {
74 writeSectorImpl(sector, buf);
82 std::span<const SectorBuffer> buffers,
size_t startSector)
86 for (
auto [i, buf] :
enumerate(buffers)) {
94 return getNbSectorsImpl();
99 patch = std::make_unique<IPSPatch>(std::move(patchFile), std::move(patch));
104 return patch->getFilenames();
109 return !patch->isEmptyPatch();
115 if (sha1cache.
empty()) {
127 std::array<SectorBuffer, 32> buf;
130 while (sector < total) {
131 auto chunk =
std::min(buf.size(), total - sector);
132 auto sub =
subspan(buf, 0, chunk);
134 sha1.
update({sub[0].raw.data(), sub.size_bytes()});
148 return forcedWriteProtect || isWriteProtectedImpl();
154 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)
virtual Sha1Sum getSha1SumImpl(FilePool &filePool)
Sha1Sum getSha1Sum(FilePool &filePool)
Calculate SHA1 of the content of this disk.
virtual void checkCaches()
void readSector(size_t sector, SectorBuffer &buf)
void readSectors(std::span< SectorBuffer > buffers, size_t startSector)
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 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....
constexpr vecN< N, T > min(const vecN< N, T > &x, const vecN< N, T > &y)
This file implemented 3 utility functions:
constexpr auto subspan(Range &&range, size_t offset, size_t count=std::dynamic_extent)