From f1663abe818d60c5c1d541cac0cb6e4b8fcae971 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 4 Apr 2021 21:43:14 -0700 Subject: [PATCH] Removes getenv usage for aotir We can't rely on `getenv("HOME")` always working. Have the AOTIR code use the helper method for getting the data directory instead. --- Source/Tests/ELFLoader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Tests/ELFLoader.cpp b/Source/Tests/ELFLoader.cpp index d03354ff9..3c6545704 100644 --- a/Source/Tests/ELFLoader.cpp +++ b/Source/Tests/ELFLoader.cpp @@ -283,7 +283,7 @@ int main(int argc, char **argv, char **const envp) { } FEXCore::Context::SetAOTIRLoader(CTX, [](const std::string &fileid) -> std::unique_ptr { - auto filepath = std::filesystem::path(getenv("HOME")) / ".fex-emu" / "aotir" / fileid; + auto filepath = std::filesystem::path(FEXCore::Config::GetDataDirectory()) / "aotir" / fileid; return std::make_unique(filepath, std::ios::in | std::ios::binary); }); @@ -291,10 +291,10 @@ int main(int argc, char **argv, char **const envp) { FEXCore::Context::RunUntilExit(CTX); if (AOTIRCapture()) { - std::filesystem::create_directories(std::filesystem::path(getenv("HOME")) / ".fex-emu" / "aotir"); + std::filesystem::create_directories(std::filesystem::path(FEXCore::Config::GetDataDirectory()) / "aotir"); auto WroteCache = FEXCore::Context::WriteAOTIR(CTX, [](const std::string& fileid) -> std::unique_ptr { - auto filepath = std::filesystem::path(getenv("HOME")) / ".fex-emu" / "aotir" / fileid; + auto filepath = std::filesystem::path(FEXCore::Config::GetDataDirectory()) / "aotir" / fileid; auto AOTWrite = std::make_unique(filepath, std::ios::out | std::ios::binary); if (*AOTWrite) { std::filesystem::resize_file(filepath, 0);