Skip to content

Commit

Permalink
[macOS] Place shadPS4/user folder in Application Support
Browse files Browse the repository at this point in the history
Partially resolves shadps4-emu#509
  • Loading branch information
mavethee committed Sep 1, 2024
1 parent 6080066 commit 7415cee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,6 @@ FodyWeavers.xsd
/out/*
/third-party/out/*
/src/common/scm_rev.cpp

# for macOS
**/.DS_Store
15 changes: 12 additions & 3 deletions src/common/path_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,20 @@ static std::filesystem::path GetBundleParentDirectory() {

static auto UserPaths = [] {
#ifdef __APPLE__
std::filesystem::current_path(GetBundleParentDirectory());
// Start by assuming the base directory is the bundle's parent directory.
std::filesystem::path base_dir = GetBundleParentDirectory();
std::filesystem::path user_dir = base_dir / PORTABLE_DIR;
// Check if the "user" directory exists in the current path:
if (!std::filesystem::exists(user_dir)) {
// If it doesn't exist, use the new hardcoded path:
user_dir =
std::filesystem::path(getenv("HOME")) / "Library" / "Application Support" / "shadPS4";
}
#else
const auto user_dir = std::filesystem::current_path() / PORTABLE_DIR;
#endif

std::unordered_map<PathType, fs::path> paths;
const auto user_dir = std::filesystem::current_path() / PORTABLE_DIR;

const auto create_path = [&](PathType shad_path, const fs::path& new_path) {
std::filesystem::create_directory(new_path);
Expand Down Expand Up @@ -155,4 +164,4 @@ void SetUserPath(PathType shad_path, const fs::path& new_path) {
UserPaths.insert_or_assign(shad_path, new_path);
}

} // namespace Common::FS
} // namespace Common::FS

0 comments on commit 7415cee

Please sign in to comment.