Skip to content

Commit

Permalink
[macOS] Place shadPS4/user folder in Application Support
Browse files Browse the repository at this point in the history
Attempts to resolve shadps4-emu#509
  • Loading branch information
mavethee committed Aug 31, 2024
1 parent 6080066 commit 4c92ccb
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/common/path_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,22 @@ 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 / "user";

// Check if the "user" directory exists in the current path:
if (!std::filesystem::exists(user_dir)) {
// If it doesn't exist, use the hardcoded path:
base_dir = std::filesystem::path(getenv("HOME")) / "Library/Application Support/shadPS4";
user_dir = base_dir / "user";
std::filesystem::create_directories(user_dir);
}
#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 +166,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 4c92ccb

Please sign in to comment.