diff options
| author | NotAShelf <itsashelf@gmail.com> | 2023-03-31 15:15:24 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-31 13:15:24 +0100 |
| commit | 3d9bf17f117640edcb5efcc361fdff4096ee072d (patch) | |
| tree | 2a58fd11a32723610e2c9a02d9b59a42879d97ad /src/debug/CrashReporter.cpp | |
| parent | 614ea53ad73ad7fc87e9d3f9bb39235d7eaeca7e (diff) | |
crashReporter: try `$XDG_CACHE_HOME` before `$HOME` (#1920)
Diffstat (limited to 'src/debug/CrashReporter.cpp')
| -rw-r--r-- | src/debug/CrashReporter.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/debug/CrashReporter.cpp b/src/debug/CrashReporter.cpp index 4037ad44..d553b7b0 100644 --- a/src/debug/CrashReporter.cpp +++ b/src/debug/CrashReporter.cpp @@ -129,18 +129,32 @@ void CrashReporter::createAndSaveCrash(int sig) { finalCrashReport += execAndGet(("cat \"" + Debug::logFile + "\" | tail -n 50").c_str()); const auto HOME = getenv("HOME"); + const auto CACHE_HOME = getenv("XDG_CACHE_HOME"); if (!HOME) return; - if (!std::filesystem::exists(std::string(HOME) + "/.hyprland")) { - std::filesystem::create_directory(std::string(HOME) + "/.hyprland"); - std::filesystem::permissions(std::string(HOME) + "/.hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace); - } + std::ofstream ofs; + if (!CACHE_HOME) { + if (!std::filesystem::exists(std::string(HOME) + "/.hyprland")) { + std::filesystem::create_directory(std::string(HOME) + "/.hyprland"); + std::filesystem::permissions(std::string(HOME) + "/.hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace); + } + + ofs.open(std::string(HOME) + "/.hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt", std::ios::trunc); + + } else if (CACHE_HOME) { + if (!std::filesystem::exists(std::string(CACHE_HOME) + "/hyprland")) { + std::filesystem::create_directory(std::string(CACHE_HOME) + "/hyprland"); + std::filesystem::permissions(std::string(CACHE_HOME) + "/hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace); + } - std::ofstream ofs(std::string(HOME) + "/.hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt", std::ios::trunc); + ofs.open(std::string(CACHE_HOME) + "/hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt", std::ios::trunc); + } else { + return; + } ofs << finalCrashReport; ofs.close(); -}
\ No newline at end of file +} |
