@@ -81,6 +81,8 @@ static const char * const logSectionName = "LogDebug";
81
81
static const char * const logSectionName = " Log" ;
82
82
#endif
83
83
84
+ static bool TryUpdateSavedPath (Path *path);
85
+
84
86
std::string GPUBackendToString (GPUBackend backend) {
85
87
switch (backend) {
86
88
case GPUBackend::OPENGL:
@@ -1147,6 +1149,9 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
1147
1149
1148
1150
iRunCount++;
1149
1151
1152
+ // For iOS, issue #19211
1153
+ TryUpdateSavedPath (¤tDirectory);
1154
+
1150
1155
// This check is probably not really necessary here anyway, you can always
1151
1156
// press Home or Browse if you're in a bad directory.
1152
1157
if (!File::Exists (currentDirectory))
@@ -1367,7 +1372,7 @@ bool Config::Save(const char *saveReason) {
1367
1372
playTimeTracker_.Save (playTime);
1368
1373
1369
1374
if (!iniFile.Save (iniFilename_)) {
1370
- ERROR_LOG (LOADER, " Error saving config (%s)- can't write ini '%s'" , saveReason, iniFilename_.c_str ());
1375
+ ERROR_LOG (LOADER, " Error saving config (%s) - can't write ini '%s'" , saveReason, iniFilename_.c_str ());
1371
1376
return false ;
1372
1377
}
1373
1378
INFO_LOG (LOADER, " Config saved (%s): '%s' (%0.1f ms)" , saveReason, iniFilename_.c_str (), (time_now_d () - startTime) * 1000.0 );
@@ -1546,6 +1551,34 @@ void Config::RemoveRecent(const std::string &file) {
1546
1551
recentIsos.erase (iter, recentIsos.end ());
1547
1552
}
1548
1553
1554
+ // On iOS, the path to the app documents directory changes on each launch.
1555
+ // Example path:
1556
+ // /var/mobile/Containers/Data/Application/0E0E89DE-8D8E-485A-860C-700D8BC87B86/Documents/PSP/GAME/SuicideBarbie
1557
+ // The GUID part changes on each launch.
1558
+ static bool TryUpdateSavedPath (Path *path) {
1559
+ #if PPSSPP_PLATFORM(IOS)
1560
+ INFO_LOG (LOADER, " Original path: %s" , path->c_str ());
1561
+ std::string pathStr = path->ToString ();
1562
+
1563
+ const std::string_view applicationRoot = " /var/mobile/Containers/Data/Application/" ;
1564
+ if (startsWith (pathStr, applicationRoot)) {
1565
+ size_t documentsPos = pathStr.find (" /Documents/" );
1566
+ if (documentsPos == std::string::npos) {
1567
+ return false ;
1568
+ }
1569
+ std::string memstick = g_Config.memStickDirectory .ToString ();
1570
+ size_t memstickDocumentsPos = memstick.find (" /Documents" ); // Note: No trailing slash, or we won't find it.
1571
+ *path = Path (memstick.substr (0 , memstickDocumentsPos) + pathStr.substr (documentsPos));
1572
+ return true ;
1573
+ } else {
1574
+ // Path can't be auto-updated.
1575
+ return false ;
1576
+ }
1577
+ #else
1578
+ return false ;
1579
+ #endif
1580
+ }
1581
+
1549
1582
void Config::CleanRecent () {
1550
1583
private_->SetRecentIsosThread ([this ] {
1551
1584
SetCurrentThreadName (" RecentISOs" );
@@ -1556,13 +1589,23 @@ void Config::CleanRecent() {
1556
1589
1557
1590
std::lock_guard<std::mutex> guard (private_->recentIsosLock );
1558
1591
std::vector<std::string> cleanedRecent;
1592
+ if (recentIsos.empty ()) {
1593
+ INFO_LOG (LOADER, " No recents list found." );
1594
+ }
1595
+
1559
1596
for (size_t i = 0 ; i < recentIsos.size (); i++) {
1560
1597
bool exists = false ;
1561
1598
Path path = Path (recentIsos[i]);
1562
1599
switch (path.Type ()) {
1563
1600
case PathType::CONTENT_URI:
1564
1601
case PathType::NATIVE:
1565
1602
exists = File::Exists (path);
1603
+ if (!exists) {
1604
+ if (TryUpdateSavedPath (&path)) {
1605
+ exists = File::Exists (path);
1606
+ INFO_LOG (LOADER, " Exists=%d when checking updated path: %s" , exists, path.c_str ());
1607
+ }
1608
+ }
1566
1609
break ;
1567
1610
default :
1568
1611
FileLoader *loader = ConstructFileLoader (path);
@@ -1572,11 +1615,14 @@ void Config::CleanRecent() {
1572
1615
}
1573
1616
1574
1617
if (exists) {
1618
+ std::string pathStr = path.ToString ();
1575
1619
// Make sure we don't have any redundant items.
1576
- auto duplicate = std::find (cleanedRecent.begin (), cleanedRecent.end (), recentIsos[i] );
1620
+ auto duplicate = std::find (cleanedRecent.begin (), cleanedRecent.end (), pathStr );
1577
1621
if (duplicate == cleanedRecent.end ()) {
1578
- cleanedRecent.push_back (recentIsos[i] );
1622
+ cleanedRecent.push_back (pathStr );
1579
1623
}
1624
+ } else {
1625
+ DEBUG_LOG (LOADER, " Removed %s from recent. errno=%d" , path.c_str (), errno);
1580
1626
}
1581
1627
}
1582
1628
0 commit comments