openMSX
DSKDiskImage.cc
Go to the documentation of this file.
1#include "DSKDiskImage.hh"
2#include "File.hh"
3#include "FilePool.hh"
4
5namespace openmsx {
6
8 : SectorBasedDisk(DiskName(fileName))
9 , file(std::make_shared<File>(fileName, File::OpenMode::PRE_CACHE))
10{
11 setNbSectors(file->getSize() / sizeof(SectorBuffer));
12}
13
15 std::shared_ptr<File> file_)
16 : SectorBasedDisk(DiskName(fileName))
17 , file(std::move(file_))
18{
19 setNbSectors(file->getSize() / sizeof(SectorBuffer));
20}
21
22void DSKDiskImage::readSectorsImpl(
23 std::span<SectorBuffer> buffers, size_t startSector)
24{
25 file->seek(startSector * sizeof(SectorBuffer));
26 file->read(buffers);
27}
28
29void DSKDiskImage::writeSectorImpl(size_t sector, const SectorBuffer& buf)
30{
31 file->seek(sector * sizeof(buf));
32 file->write(buf.raw);
33}
34
35bool DSKDiskImage::isWriteProtectedImpl() const
36{
37 return file->isReadOnly();
38}
39
40Sha1Sum DSKDiskImage::getSha1SumImpl(FilePool& filePool)
41{
42 if (hasPatches()) {
44 }
45 return filePool.getSha1Sum(*file);
46}
47
48} // namespace openmsx
DSKDiskImage(const Filename &filename)
This class represents a filename.
Definition Filename.hh:20
virtual Sha1Sum getSha1SumImpl(FilePool &filePool)
Abstract class for disk images that only represent the logical sector information (so not the raw tra...
void setNbSectors(size_t num)
This file implemented 3 utility functions:
Definition Autofire.cc:11
STL namespace.