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