reporter: Migrate to the new Common::FS library
This commit is contained in:
@@ -11,7 +11,9 @@
|
|||||||
#include <fmt/ostream.h>
|
#include <fmt/ostream.h>
|
||||||
#include <nlohmann/json.hpp>
|
#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/hex_util.h"
|
||||||
#include "common/scm_rev.h"
|
#include "common/scm_rev.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
@@ -26,10 +28,9 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::string GetPath(std::string_view type, u64 title_id, std::string_view timestamp) {
|
std::filesystem::path GetPath(std::string_view type, u64 title_id, std::string_view timestamp) {
|
||||||
return fmt::format("{}{}/{:016X}_{}.json",
|
return Common::FS::GetYuzuPath(Common::FS::YuzuPath::LogDir) / type /
|
||||||
Common::FS::GetUserPath(Common::FS::UserPath::LogDir), type, title_id,
|
fmt::format("{:016X}_{}.json", title_id, timestamp);
|
||||||
timestamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetTimestamp() {
|
std::string GetTimestamp() {
|
||||||
@@ -39,14 +40,16 @@ std::string GetTimestamp() {
|
|||||||
|
|
||||||
using namespace nlohmann;
|
using namespace nlohmann;
|
||||||
|
|
||||||
void SaveToFile(json json, const std::string& filename) {
|
void SaveToFile(json json, const std::filesystem::path& filename) {
|
||||||
if (!Common::FS::CreateFullPath(filename)) {
|
if (!Common::FS::CreateParentDirs(filename)) {
|
||||||
LOG_ERROR(Core, "Failed to create path for '{}' to save report!", filename);
|
LOG_ERROR(Core, "Failed to create path for '{}' to save report!",
|
||||||
|
Common::FS::PathToUTF8String(filename));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream file(
|
std::ofstream file;
|
||||||
Common::FS::SanitizePath(filename, Common::FS::DirectorySeparator::PlatformDefault));
|
Common::FS::OpenFileStream(file, filename, std::ios_base::out | std::ios_base::trunc);
|
||||||
|
|
||||||
file << std::setw(4) << json << std::endl;
|
file << std::setw(4) << json << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user