From 544d6ba1b93882e462e4ff9988ab2a16091decd6 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 26 Sep 2024 07:30:26 +0930 Subject: [PATCH] Core: Normalize Path for RomList_RomListCache --- Source/Project64-core/N64System/N64Rom.cpp | 1 + Source/Project64-core/RomList/RomList.cpp | 6 +++--- Source/Project64/UserInterface/RomBrowser.cpp | 16 +++------------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Source/Project64-core/N64System/N64Rom.cpp b/Source/Project64-core/N64System/N64Rom.cpp index 8bdcdff99..f502f2e9f 100644 --- a/Source/Project64-core/N64System/N64Rom.cpp +++ b/Source/Project64-core/N64System/N64Rom.cpp @@ -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) diff --git a/Source/Project64-core/RomList/RomList.cpp b/Source/Project64-core/RomList/RomList.cpp index 27483335b..5713258ea 100644 --- a/Source/Project64-core/RomList/RomList.cpp +++ b/Source/Project64-core/RomList/RomList.cpp @@ -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); diff --git a/Source/Project64/UserInterface/RomBrowser.cpp b/Source/Project64/UserInterface/RomBrowser.cpp index 85ea646ba..b88606d78 100644 --- a/Source/Project64/UserInterface/RomBrowser.cpp +++ b/Source/Project64/UserInterface/RomBrowser.cpp @@ -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 (...)