diff options
Diffstat (limited to 'src/core/reporter.cpp')
-rw-r--r-- | src/core/reporter.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index d1e807dd4..a9596fe4d 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp @@ -11,7 +11,9 @@ #include <fmt/ostream.h> #include <nlohmann/json.hpp> -#include "common/file_util.h" +#include "common/fs/file.h" +#include "common/fs/fs.h" +#include "common/fs/path_util.h" #include "common/hex_util.h" #include "common/scm_rev.h" #include "common/settings.h" @@ -26,10 +28,9 @@ namespace { -std::string GetPath(std::string_view type, u64 title_id, std::string_view timestamp) { - return fmt::format("{}{}/{:016X}_{}.json", - Common::FS::GetUserPath(Common::FS::UserPath::LogDir), type, title_id, - timestamp); +std::filesystem::path GetPath(std::string_view type, u64 title_id, std::string_view timestamp) { + return Common::FS::GetYuzuPath(Common::FS::YuzuPath::LogDir) / type / + fmt::format("{:016X}_{}.json", title_id, timestamp); } std::string GetTimestamp() { @@ -39,14 +40,16 @@ std::string GetTimestamp() { using namespace nlohmann; -void SaveToFile(json json, const std::string& filename) { - if (!Common::FS::CreateFullPath(filename)) { - LOG_ERROR(Core, "Failed to create path for '{}' to save report!", filename); +void SaveToFile(json json, const std::filesystem::path& filename) { + if (!Common::FS::CreateParentDirs(filename)) { + LOG_ERROR(Core, "Failed to create path for '{}' to save report!", + Common::FS::PathToUTF8String(filename)); return; } - std::ofstream file( - Common::FS::SanitizePath(filename, Common::FS::DirectorySeparator::PlatformDefault)); + std::ofstream file; + Common::FS::OpenFileStream(file, filename, std::ios_base::out | std::ios_base::trunc); + file << std::setw(4) << json << std::endl; } |