mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 05:40:01 -06:00
Wrapped fopen/close/read/write functions inside a simple "IOFile" class. Reading, writing, and error checking became simpler in most cases. It should be near impossible to forget to close a file now that the destructor takes care of it. (I hope this fixes Issue 3635) I have tested the functionality of most things, but it is possible I broke something. :p
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7328 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -52,20 +52,14 @@ std::string CreateTitleContentPath(u64 _titleID)
|
||||
|
||||
bool CheckTitleTMD(u64 _titleID)
|
||||
{
|
||||
std::string TitlePath;
|
||||
TitlePath = CreateTitleContentPath(_titleID) + "/title.tmd";
|
||||
const std::string TitlePath = CreateTitleContentPath(_titleID) + "/title.tmd";
|
||||
if (File::Exists(TitlePath))
|
||||
{
|
||||
FILE* pTMDFile = fopen(TitlePath.c_str(), "rb");
|
||||
if(pTMDFile)
|
||||
{
|
||||
u64 TitleID = 0xDEADBEEFDEADBEEFULL;
|
||||
fseeko(pTMDFile, 0x18C, SEEK_SET);
|
||||
fread(&TitleID, 8, 1, pTMDFile);
|
||||
fclose(pTMDFile);
|
||||
if (_titleID == Common::swap64(TitleID))
|
||||
return true;
|
||||
}
|
||||
File::IOFile pTMDFile(TitlePath, "rb");
|
||||
u64 TitleID = 0;
|
||||
pTMDFile.Seek(0x18C, SEEK_SET);
|
||||
if (pTMDFile.ReadArray(&TitleID, 1) && _titleID == Common::swap64(TitleID))
|
||||
return true;
|
||||
}
|
||||
INFO_LOG(DISCIO, "Invalid or no tmd for title %08x %08x", (u32)(_titleID >> 32), (u32)(_titleID & 0xFFFFFFFF));
|
||||
return false;
|
||||
@ -73,19 +67,14 @@ bool CheckTitleTMD(u64 _titleID)
|
||||
|
||||
bool CheckTitleTIK(u64 _titleID)
|
||||
{
|
||||
std::string TikPath = Common::CreateTicketFileName(_titleID);
|
||||
const std::string TikPath = Common::CreateTicketFileName(_titleID);
|
||||
if (File::Exists(TikPath))
|
||||
{
|
||||
FILE* pTIKFile = fopen(TikPath.c_str(), "rb");
|
||||
if(pTIKFile)
|
||||
{
|
||||
u64 TitleID = 0xDEADBEEFDEADBEEFULL;
|
||||
fseeko(pTIKFile, 0x1dC, SEEK_SET);
|
||||
fread(&TitleID, 8, 1, pTIKFile);
|
||||
fclose(pTIKFile);
|
||||
if (_titleID == Common::swap64(TitleID))
|
||||
return true;
|
||||
}
|
||||
File::IOFile pTIKFile(TikPath, "rb");
|
||||
u64 TitleID = 0;
|
||||
pTIKFile.Seek(0x1dC, SEEK_SET);
|
||||
if (pTIKFile.ReadArray(&TitleID, 1) && _titleID == Common::swap64(TitleID))
|
||||
return true;
|
||||
}
|
||||
INFO_LOG(DISCIO, "Invalid or no tik for title %08x %08x", (u32)(_titleID >> 32), (u32)(_titleID & 0xFFFFFFFF));
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user