diff --git a/.gitignore b/.gitignore index 2a314508..087f2968 100644 --- a/.gitignore +++ b/.gitignore @@ -409,3 +409,6 @@ FodyWeavers.xsd /out/* /third-party/out/* /src/common/scm_rev.cpp + +# for macOS +**/.DS_Store \ No newline at end of file diff --git a/src/common/path_util.cpp b/src/common/path_util.cpp index 8d369fc7..e6c1fc1a 100644 --- a/src/common/path_util.cpp +++ b/src/common/path_util.cpp @@ -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 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 \ No newline at end of file