Skip to content

Commit

Permalink
Updates to Context.cpp for macOS Game mode support (#690)
Browse files Browse the repository at this point in the history
* Update Context.cpp

* Removed mkdir from LUS

Also merged expand tilde and the #if defined(__APPLE__) in GetAppDirectoryPath since it was only used there.

* fixed an oopsie

* Update Context.cpp

* Removed the 4 spaces from the accidental tab.
  • Loading branch information
larsy1995 authored Oct 20, 2024
1 parent f40626b commit 736ad68
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#ifdef __APPLE__
#include "utils/AppleFolderManager.h"
#include <unistd.h>
#include <pwd.h>
#endif

namespace Ship {
Expand Down Expand Up @@ -368,7 +370,17 @@ std::string Context::GetAppDirectoryPath(std::string appName) {
return std::string(home) + "/Documents";
#endif

#if defined(__linux__) || defined(__APPLE__)
#if defined(__APPLE__)
if (char* fpath = std::getenv("SHIP_HOME")) {
if (fpath[0] == '~') {
const char* home = getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir;
return std::string(home) + std::string(fpath).substr(1);
}
return std::string(fpath);
}
#endif

#if defined(__linux__)
char* fpath = std::getenv("SHIP_HOME");
if (fpath != NULL) {
return std::string(fpath);
Expand Down

0 comments on commit 736ad68

Please sign in to comment.