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

Method OpenFile

pcsx2/Elfheader.cpp:58–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58bool ElfObject::OpenFile(std::string srcfile, bool isPSXElf_, Error* error)
59{
60 auto fp = FileSystem::OpenManagedCFile(srcfile.c_str(), "rb", error);
61 FILESYSTEM_STAT_DATA sd;
62 if (!fp || !FileSystem::StatFile(fp.get(), &sd))
63 {
64 Error::SetString(error, fmt::format("Failed to read ELF from '{}'", srcfile));
65 return false;
66 }
67
68 if (!isPSXElf_ && !CheckElfSize(sd.Size, error))
69 return false;
70
71 data.resize(static_cast<size_t>(sd.Size));
72 if (std::fread(data.data(), data.size(), 1, fp.get()) != 1)
73 {
74 Error::SetString(error, fmt::format("Failed to read ELF from '{}'", srcfile));
75 return false;
76 }
77
78 filename = std::move(srcfile);
79 isPSXElf = isPSXElf_;
80 InitElfHeaders();
81 return true;
82}
83
84void ElfObject::InitElfHeaders()
85{

Callers 4

GetElfListEntryMethod · 0.80
cdvdLoadElfFunction · 0.80
cdvdGetElfCRCFunction · 0.80

Calls 6

formatFunction · 0.50
c_strMethod · 0.45
getMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected