UnleashedRecomp/UnleashedRecomp/user/paths.h
2025-08-03 18:56:42 +03:00

45 lines
1.2 KiB
C++

#pragma once
#include <mod/mod_loader.h>
#define USER_DIRECTORY "UnleashedRecomp"
#ifndef GAME_INSTALL_DIRECTORY
#define GAME_INSTALL_DIRECTORY "."
#endif
extern std::filesystem::path g_executableRoot;
bool CheckPortable();
std::filesystem::path BuildUserPath();
const std::filesystem::path& GetUserPath();
inline std::filesystem::path GetGamePath()
{
#ifdef __APPLE__
// On macOS, there is the expectation that the app may be installed to
// /Applications/, and the bundle should not be modified. Thus we need
// to install game files to the user directory instead of next to the app.
return GetUserPath();
#else
return GAME_INSTALL_DIRECTORY;
#endif
}
inline std::filesystem::path GetSavePath(bool checkForMods)
{
if (checkForMods && !ModLoader::s_saveFilePath.empty())
return ModLoader::s_saveFilePath.parent_path();
else
return GetUserPath() / "save";
}
// Returned file name may not necessarily be
// equal to SYS-DATA as mods can assign anything.
inline std::filesystem::path GetSaveFilePath(bool checkForMods)
{
if (checkForMods && !ModLoader::s_saveFilePath.empty())
return ModLoader::s_saveFilePath;
else
return GetSavePath(false) / "SYS-DATA";
}