2016-12-28 21:39:38 +00:00
|
|
|
#include "CMemoryCardSys.hpp"
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-12-28 21:39:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
kabufuda::SystemString CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
|
|
|
|
const char* home = getenv("HOME");
|
|
|
|
if (!home)
|
|
|
|
return {};
|
2016-12-28 21:39:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
kabufuda::SystemString path = home;
|
|
|
|
path += hecl::Format("/Library/Application Support/Dolphin/GC/MemoryCard%c.USA.raw",
|
|
|
|
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
2016-12-28 21:39:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::Sstat theStat;
|
|
|
|
if (hecl::Stat(path.c_str(), &theStat) || !S_ISREG(theStat.st_mode))
|
|
|
|
return {};
|
2016-12-28 21:39:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return path;
|
2016-12-28 21:39:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
kabufuda::SystemString CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot) {
|
|
|
|
const char* home = getenv("HOME");
|
|
|
|
if (!home)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
kabufuda::SystemString path = home;
|
|
|
|
path += "/Library/Application Support/Dolphin/GC";
|
|
|
|
if (hecl::RecursiveMakeDir(path.c_str()) < 0)
|
|
|
|
return {};
|
2017-02-04 03:46:12 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
path += hecl::Format("/MemoryCard%c.USA.raw", slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
|
|
|
FILE* fp = hecl::Fopen(path.c_str(), "wb");
|
|
|
|
if (!fp)
|
|
|
|
return {};
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
return path;
|
2016-12-28 21:39:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
} // namespace urde
|