2015-08-17 22:05:00 +00:00
|
|
|
#include "CMemoryCardSys.hpp"
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-17 22:05:00 +00:00
|
|
|
{
|
|
|
|
|
2016-12-28 21:39:38 +00:00
|
|
|
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 =
|
2016-12-28 23:03:37 +00:00
|
|
|
((dataHome && dataHome[0] == '/') ? dataHome : hecl::SystemString(home)) + "/.local/share/dolphin-emu";
|
2016-12-28 21:39:38 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-08-17 22:05:00 +00:00
|
|
|
}
|