2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 21:47:42 +00:00

Kabufuda updates and dolphin memory card path resolution

This commit is contained in:
Jack Andersen
2016-12-28 11:39:38 -10:00
parent 563ff28848
commit fe3d375120
7 changed files with 216 additions and 28 deletions

View File

@@ -3,4 +3,31 @@
namespace urde
{
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot)
{
const char* home = getenv("HOME");
if (!home || home[0] != '/')
return {};
const char* dataHome = getenv("XDG_DATA_HOME");
/* XDG-selected data path */
kabufuda::SystemString path =
(dataHome && dataHome[0] == '/') ? dataHome : (home + "/.local/share") + "/.dolphin-emu";
path += hecl::Format("/GC/MemoryCard%c.USA.raw",
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
hecl::Sstat theStat;
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode))
{
/* legacy case for older dolphin versions */
path = home;
path += hecl::Format("/.dolphin-emu/GC/MemoryCard%c.USA.raw",
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode))
return {};
}
return path;
}
}