MCPcopy Create free account
hub / github.com/PiSCSI/piscsi / Load

Method Load

cpp/devices/disk_cache.cpp:146–176  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Load cache ---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

144//
145//---------------------------------------------------------------------------
146bool DiskCache::Load(int index, int64_t track, shared_ptr<DiskTrack> disktrk)
147{
148 assert(index >= 0 && index < static_cast<int>(cache.size()));
149 assert(track >= 0);
150 assert(cache[index].disktrk == nullptr);
151
152 // Get the number of sectors on this track
153 int64_t sectors = sec_blocks - (track << 8);
154 assert(sectors > 0);
155 if (sectors > 0x100) {
156 sectors = 0x100;
157 }
158
159 if (disktrk == nullptr) {
160 disktrk = make_shared<DiskTrack>();
161 }
162
163 disktrk->Init(track, sec_size, sectors, cd_raw, imgoffset);
164
165 // Try loading
166 if (!disktrk->Load(sec_path, cache_miss_read_count)) {
167 ++read_error_count;
168
169 return false;
170 }
171
172 // Allocation successful, work set
173 cache[index].disktrk = disktrk;
174
175 return true;
176}
177
178void DiskCache::UpdateSerialNumber()
179{

Callers

nothing calls this directly

Calls 1

InitMethod · 0.45

Tested by

no test coverage detected