MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Open2

Method Open2

pcsx2/CDVD/ChdFileReader.cpp:367–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365}
366
367bool ChdFileReader::Open2(std::string filename, Error* error)
368{
369 Close2();
370
371 m_filename = std::move(filename);
372
373 auto fp = FileSystem::OpenManagedSharedCFile(m_filename.c_str(), "rb", FileSystem::FileShareMode::DenyWrite, error);
374 if (!fp)
375 return false;
376
377 ChdFile = OpenCHD(m_filename, std::move(fp), error, 0);
378 if (!ChdFile)
379 return false;
380
381 const chd_header* chd_header = chd_get_header(ChdFile);
382 hunk_size = chd_header->hunkbytes;
383 // CHD likes to use full 2448 byte blocks, but keeps the +24 offset of source ISOs
384 // The rest of PCSX2 likes to use 2448 byte buffers, which can't fit that so trim blocks instead
385 m_internalBlockSize = chd_header->unitbytes;
386
387 // The file size in the header is incorrect, each track gets padded to a multiple of 4 frames.
388 // (see chdman.cpp from MAME). Instead, we pull the real frame count from the TOC.
389 u64 total_frames;
390 if (ParseTOC(&total_frames))
391 {
392 file_size = total_frames * static_cast<u64>(chd_header->unitbytes);
393 }
394 else
395 {
396 Console.Warning("Failed to parse CHD TOC, file size may be incorrect.");
397 file_size = static_cast<u64>(chd_header->unitbytes) * chd_header->unitcount;
398 }
399
400 return true;
401}
402
403bool ChdFileReader::Precache2(ProgressCallback* progress, Error* error)
404{

Callers

nothing calls this directly

Calls 4

OpenCHDFunction · 0.85
chd_get_headerFunction · 0.85
c_strMethod · 0.45
WarningMethod · 0.45

Tested by

no test coverage detected