Core: Normalize Path for RomList_RomListCache

This commit is contained in:
zilmar 2024-09-26 07:30:26 +09:30
parent cd9fc5984a
commit 544d6ba1b9
3 changed files with 7 additions and 16 deletions

View File

@ -299,6 +299,7 @@ CICChip CN64Rom::GetCicChipID(uint8_t * RomData, uint64_t * CRC)
case 0x000000D2E53EF39F: return CIC_NUS_8401; // 64DD IPL tool
case 0x000000D2E53E5DDA: return CIC_NUS_DDUS; // 64DD IPL US (different CIC)
case 0x0000000AF3A34BC8: return CIC_MINI_IPL3;
case 0x0000007c56242373: return CIC_NUS_6102; // LibDragon IPL3
default:
//Aleck64 CIC
if (crcAleck64 == 0x000000A5F80BF620)

View File

@ -112,7 +112,7 @@ void CRomList::RefreshRomListThread(void)
{
WriteTrace(TraceRomList, TraceVerbose, "Start");
// Delete cache
CPath(g_Settings->LoadStringVal(RomList_RomListCache)).Delete();
CPath(g_Settings->LoadStringVal(RomList_RomListCache)).NormalizePath(CPath::MODULE_DIRECTORY).Delete();
WriteTrace(TraceRomList, TraceVerbose, "Cache deleted");
// Clear all current items
@ -689,7 +689,7 @@ void CRomList::ByteSwapRomData(uint8_t * Data, int32_t DataLen)
void CRomList::LoadRomList(void)
{
WriteTrace(TraceRomList, TraceVerbose, "Start");
CPath FileName(g_Settings->LoadStringVal(RomList_RomListCache));
CPath FileName = CPath(g_Settings->LoadStringVal(RomList_RomListCache)).NormalizePath(CPath::MODULE_DIRECTORY);
CFile file(FileName, CFileBase::modeRead | CFileBase::modeNoTruncate);
if (!file.IsOpen())
@ -741,7 +741,7 @@ void CRomList::SaveRomList(strlist & FileList)
{
MD5 ListHash = RomListHash(FileList);
CPath FileName(g_Settings->LoadStringVal(RomList_RomListCache));
CPath FileName = CPath(g_Settings->LoadStringVal(RomList_RomListCache)).NormalizePath(CPath::MODULE_DIRECTORY);
CFile file(FileName, CFileBase::modeWrite | CFileBase::modeCreate);
file.Write(ListHash.raw_digest(), 16);

View File

@ -1263,14 +1263,14 @@ bool CRomBrowser::RomDirNeedsRefresh(void)
bool InWatchThread = (m_WatchThreadID == GetCurrentThreadId());
// Get old MD5 of file names
stdstr FileName = g_Settings->LoadStringVal(RomList_RomListCache);
if (!CPath(FileName).Exists())
CPath FileName = CPath(g_Settings->LoadStringVal(RomList_RomListCache)).NormalizePath(CPath::MODULE_DIRECTORY);
if (!FileName.Exists())
{
// If file does not exist then refresh the data
return true;
}
CFile hFile(FileName.c_str(), CFileBase::modeRead);
CFile hFile(FileName, CFileBase::modeRead);
if (!hFile.IsOpen())
{
// Could not validate, assume it is fine
@ -1301,41 +1301,31 @@ void CRomBrowser::WatchRomDirChanged(CRomBrowser * _this)
{
try
{
WriteTrace(TraceUserInterface, TraceDebug, "1");
_this->m_WatchRomDir = g_Settings->LoadStringVal(RomList_GameDir);
WriteTrace(TraceUserInterface, TraceDebug, "2");
if (_this->RomDirNeedsRefresh())
{
WriteTrace(TraceUserInterface, TraceDebug, "2a");
_this->RomDirChanged();
}
WriteTrace(TraceUserInterface, TraceDebug, "3");
HANDLE hChange[] = {
_this->m_WatchStopEvent,
FindFirstChangeNotificationA(_this->m_WatchRomDir.c_str(), g_Settings->LoadBool(RomList_GameDirRecursive), FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE),
};
WriteTrace(TraceUserInterface, TraceDebug, "4");
for (;;)
{
WriteTrace(TraceUserInterface, TraceDebug, "5");
if (WaitForMultipleObjects(sizeof(hChange) / sizeof(hChange[0]), hChange, false, INFINITE) == WAIT_OBJECT_0)
{
WriteTrace(TraceUserInterface, TraceDebug, "5a");
FindCloseChangeNotification(hChange[1]);
return;
}
WriteTrace(TraceUserInterface, TraceDebug, "5b");
if (_this->RomDirNeedsRefresh())
{
_this->RomDirChanged();
}
WriteTrace(TraceUserInterface, TraceDebug, "5c");
if (!FindNextChangeNotification(hChange[1]))
{
FindCloseChangeNotification(hChange[1]);
return;
}
WriteTrace(TraceUserInterface, TraceDebug, "5d");
}
}
catch (...)