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::readSectorImpl(size_t sector, SectorBuffer& buf)
23 {
24  file->seek(sector * sizeof(buf));
25  file->read(&buf, sizeof(buf));
26 }
27 
28 void DSKDiskImage::writeSectorImpl(size_t sector, const SectorBuffer& buf)
29 {
30  file->seek(sector * sizeof(buf));
31  file->write(&buf, sizeof(buf));
32 }
33 
34 bool DSKDiskImage::isWriteProtectedImpl() const
35 {
36  return file->isReadOnly();
37 }
38 
39 Sha1Sum DSKDiskImage::getSha1SumImpl(FilePool& filePool)
40 {
41  if (hasPatches()) {
42  return SectorAccessibleDisk::getSha1SumImpl(filePool);
43  }
44  return filePool.getSha1Sum(*file);
45 }
46 
47 } // namespace openmsx
openmsx::SectorAccessibleDisk::getSha1SumImpl
virtual Sha1Sum getSha1SumImpl(FilePool &filepool)
Definition: SectorAccessibleDisk.cc:81
DSKDiskImage.hh
openmsx::SectorBuffer
Definition: DiskImageUtils.hh:90
openmsx::SectorAccessibleDisk::hasPatches
bool hasPatches() const
Definition: SectorAccessibleDisk.cc:67
File.hh
openmsx::SectorBasedDisk::setNbSectors
void setNbSectors(size_t num)
Definition: SectorBasedDisk.cc:147
FilePool.hh
openmsx::File
Definition: File.hh:16
openmsx::SectorBasedDisk
Abstract class for disk images that only represent the logical sector information (so not the raw tra...
Definition: SectorBasedDisk.hh:14
openmsx::DSKDiskImage::DSKDiskImage
DSKDiskImage(const Filename &filename)
Definition: DSKDiskImage.cc:7
openmsx::Filename
This class represents a filename.
Definition: Filename.hh:18
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5