Merge CMemoryCardSysOSX and CMemoryCardSysNix

This commit is contained in:
Phillip Stephens 2022-02-24 16:16:49 -08:00
parent ad0affb11d
commit b5a4bc0c93
3 changed files with 12 additions and 6 deletions

View File

@ -4,6 +4,7 @@
#include <cstdint> #include <cstdint>
#include <cstdlib> #include <cstdlib>
#include <algorithm> #include <algorithm>
#include <string>
#ifndef _WIN32 #ifndef _WIN32
#include <sys/stat.h> #include <sys/stat.h>
#else #else

View File

@ -24,8 +24,8 @@ add_subdirectory(Particle)
if (WIN32) if (WIN32)
list(APPEND PLAT_SRCS CMemoryCardSysWin.cpp) list(APPEND PLAT_SRCS CMemoryCardSysWin.cpp)
elseif (APPLE) #elseif (APPLE)
list(APPEND PLAT_SRCS CMemoryCardSysOSX.cpp) #list(APPEND PLAT_SRCS CMemoryCardSysOSX.cpp)
else () else ()
list(APPEND PLAT_SRCS CMemoryCardSysNix.cpp) list(APPEND PLAT_SRCS CMemoryCardSysNix.cpp)
endif () endif ()

View File

@ -1,7 +1,7 @@
#include "CMemoryCardSys.hpp" #include "CMemoryCardSys.hpp"
#include "Runtime/GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/IMain.hpp" #include "Runtime/IMain.hpp"
#include <Runtime/CBasics.hpp>
#include <SDL_filesystem.h> #include <SDL_filesystem.h>
namespace metaforce { namespace metaforce {
@ -25,8 +25,8 @@ std::string CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
auto path = *dolphinPath; auto path = *dolphinPath;
path += fmt::format(FMT_STRING("GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B'); path += fmt::format(FMT_STRING("GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
struct stat64 theStat {}; CBasics::Sstat theStat{};
if (stat64(path.c_str(), &theStat) != 0 || !S_ISREG(theStat.st_mode)) { if (CBasics::Stat(path.c_str(), &theStat) != 0 || !S_ISREG(theStat.st_mode)) {
/* legacy case for older dolphin versions */ /* legacy case for older dolphin versions */
const char* home = getenv("HOME"); const char* home = getenv("HOME");
if (home == nullptr || home[0] != '/') { if (home == nullptr || home[0] != '/') {
@ -34,9 +34,14 @@ std::string CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
} }
path = home; path = home;
#ifndef __APPLE__
path += fmt::format(FMT_STRING("/.dolphin-emu/GC/MemoryCard{:c}.USA.raw"), path += fmt::format(FMT_STRING("/.dolphin-emu/GC/MemoryCard{:c}.USA.raw"),
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B'); slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
if (stat64(path.c_str(), &theStat) != 0 || !S_ISREG(theStat.st_mode)) { #else
path += fmt::format(FMT_STRING("/Library/Application Support/Dolphin/GC/MemoryCard{:c}.USA.raw"),
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
#endif
if (CBasics::Stat(path.c_str(), &theStat) != 0 || !S_ISREG(theStat.st_mode)) {
return {}; return {};
} }
} }