Merge pull request #677 from mavethee/macos-path

[macOS] Place `shadPS4/user` folder in `Application Support`
This commit is contained in:
georgemoralis 2024-09-01 17:33:33 +03:00 committed by GitHub
commit dbc603cdc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

3
.gitignore vendored
View file

@ -409,3 +409,6 @@ FodyWeavers.xsd
/out/*
/third-party/out/*
/src/common/scm_rev.cpp
# for macOS
**/.DS_Store

View file

@ -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);
@ -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