[Base] Removed useless path_to_utf8 conversion while using fmt

Default filesystem::path formatter was added to fmt around 2022
This commit is contained in:
Gliniak 2024-12-13 19:04:31 +01:00
parent 3318ab5d4c
commit a295ec1bbd
18 changed files with 55 additions and 78 deletions

View File

@ -16,8 +16,6 @@
#include <string>
#include <utility>
#include "third_party/fmt/include/fmt/chrono.h"
#include "third_party/fmt/include/fmt/format.h"
#include "third_party/imgui/imgui.h"
#include "third_party/stb/stb_image_write.h"
#include "third_party/tomlplusplus/toml.hpp"
@ -986,7 +984,7 @@ void EmulatorWindow::SaveImage(const std::filesystem::path& filepath,
const xe::ui::RawImage& image) {
auto file = std::ofstream(filepath, std::ios::binary);
if (!file.is_open()) {
XELOGE("Failed to open file for writing: {}", xe::path_to_utf8(filepath));
XELOGE("Failed to open file for writing: {}", filepath);
return;
}
@ -998,7 +996,7 @@ void EmulatorWindow::SaveImage(const std::filesystem::path& filepath,
&file, image.width, image.height, 4, image.data.data(),
(int)image.stride);
if (result == 0) {
XELOGE("Failed to write PNG to file: {}", xe::path_to_utf8(filepath));
XELOGE("Failed to write PNG to file: {}", filepath);
return;
}
}
@ -1212,12 +1210,11 @@ void EmulatorWindow::ExtractZarchive() {
// delete incomplete output file
std::filesystem::remove(abs_extract_dir, ec);
summary +=
fmt::format("\nFailed: {}", path_to_utf8(zarchive_file_path));
summary += fmt::format("\nFailed: {}", zarchive_file_path);
XELOGE("Failed to extract Zarchive package.", result);
} else {
summary += fmt::format("\nSuccess: {}", path_to_utf8(abs_extract_dir));
summary += fmt::format("\nSuccess: {}", abs_extract_dir);
}
}
@ -1313,11 +1310,11 @@ void EmulatorWindow::CreateZarchive() {
// delete incomplete output file
std::filesystem::remove(zarchive_file, ec);
summary += fmt::format("\nFailed: {}", path_to_utf8(abs_content_dir));
summary += fmt::format("\nFailed: {}", abs_content_dir);
XELOGE("Failed to create Zarchive package.", result);
} else {
summary += fmt::format("\nSuccess: {}", path_to_utf8(zarchive_file));
summary += fmt::format("\nSuccess: {}", zarchive_file);
}
}
@ -1962,8 +1959,7 @@ xe::X_STATUS EmulatorWindow::RunTitle(
path_to_file.empty() ? "empty" : "invalid");
if (!path_to_file.empty() && !titleExists) {
log_msg.append(
fmt::format("\nProvided Path: {}", xe::path_to_utf8(path_to_file)));
log_msg.append(fmt::format("\nProvided Path: {}", path_to_file));
}
if (ec) {

View File

@ -61,8 +61,6 @@
#include "xenia/hid/xinput/xinput_hid.h"
#endif // XE_PLATFORM_WIN32
#include "third_party/fmt/include/fmt/format.h"
DEFINE_string(apu, "any", "Audio system. Use: [any, nop, sdl, xaudio2]", "APU");
DEFINE_string(gpu, "any", "Graphics system. Use: [any, d3d12, vulkan, null]",
"GPU");
@ -408,7 +406,7 @@ bool EmulatorApp::OnInitialize() {
}
}
storage_root = std::filesystem::absolute(storage_root);
XELOGI("Storage root: {}", xe::path_to_utf8(storage_root));
XELOGI("Storage root: {}", storage_root);
config::SetupConfig(storage_root);
@ -423,7 +421,7 @@ bool EmulatorApp::OnInitialize() {
}
}
content_root = std::filesystem::absolute(content_root);
XELOGI("Content root: {}", xe::path_to_utf8(content_root));
XELOGI("Content root: {}", content_root);
std::filesystem::path cache_root = cvars::cache_root;
if (cache_root.empty()) {
@ -438,7 +436,7 @@ bool EmulatorApp::OnInitialize() {
}
}
cache_root = std::filesystem::absolute(cache_root);
XELOGI("Host cache root: {}", xe::path_to_utf8(cache_root));
XELOGI("Host cache root: {}", cache_root);
if (cvars::discord) {
discord::DiscordPresence::Initialize();

View File

@ -15,6 +15,7 @@
#include <string>
#include "third_party/fmt/include/fmt/format.h"
#include "third_party/fmt/include/fmt/std.h"
#include "xenia/base/string.h"
namespace xe {

View File

@ -47,7 +47,7 @@ toml::parse_result ParseConfig(const std::filesystem::path& config_path) {
return ParseFile(config_path);
} catch (toml::parse_error& e) {
xe::FatalError(fmt::format("Failed to parse config file '{}':\n\n{}",
xe::path_to_utf8(config_path), e.what()));
config_path, e.what()));
return toml::parse_result();
}
}
@ -118,7 +118,7 @@ void ReadConfig(const std::filesystem::path& file_path,
cvar::IConfigVarUpdate::ApplyUpdates(config_defaults_date);
}
XELOGI("Loaded config: {}", xe::path_to_utf8(file_path));
XELOGI("Loaded config: {}", file_path);
}
void ReadGameConfig(const std::filesystem::path& file_path) {
@ -136,7 +136,7 @@ void ReadGameConfig(const std::filesystem::path& file_path) {
config_var->LoadConfigValue(config_key_node.node());
}
}
XELOGI("Loaded game config: {}", xe::path_to_utf8(file_path));
XELOGI("Loaded game config: {}", file_path);
}
void SaveConfig() {
@ -236,7 +236,7 @@ void SaveConfig() {
auto handle = xe::filesystem::OpenFile(config_path, "wb");
if (!handle) {
XELOGE("Failed to open '{}' for writing.", xe::path_to_utf8(config_path));
XELOGE("Failed to open '{}' for writing.", config_path);
} else {
fwrite(sb.buffer(), 1, sb.length(), handle);
fclose(handle);

View File

@ -68,13 +68,11 @@ class TestSuite {
bool Load() {
if (!ReadMap()) {
XELOGE("Unable to read map for test {}",
xe::path_to_utf8(src_file_path_));
XELOGE("Unable to read map for test {}", src_file_path_);
return false;
}
if (!ReadAnnotations()) {
XELOGE("Unable to read annotations for test {}",
xe::path_to_utf8(src_file_path_));
XELOGE("Unable to read annotations for test {}", src_file_path_);
return false;
}
return true;
@ -152,7 +150,7 @@ class TestSuite {
current_test_case = FindTestCase(label);
if (!current_test_case) {
XELOGE("Test case {} not found in corresponding map for {}", label,
xe::path_to_utf8(src_file_path_));
src_file_path_);
return false;
}
} else if (strlen(start) > 3 && start[0] == '#' && start[1] == '_') {
@ -167,8 +165,7 @@ class TestSuite {
value.erase(value.end() - 1);
}
if (!current_test_case) {
XELOGE("Annotation outside of test case in {}",
xe::path_to_utf8(src_file_path_));
XELOGE("Annotation outside of test case in {}", src_file_path_);
return false;
}
current_test_case->annotations.emplace_back(key, value);
@ -221,8 +218,7 @@ class TestRunner {
// Load the binary module.
auto module = std::make_unique<xe::cpu::RawModule>(processor_.get());
if (!module->LoadFile(START_ADDRESS, suite.bin_file_path())) {
XELOGE("Unable to load test binary {}",
xe::path_to_utf8(suite.bin_file_path()));
XELOGE("Unable to load test binary {}", suite.bin_file_path());
return false;
}
processor_->AddModule(std::move(module));
@ -449,7 +445,7 @@ bool RunTests(const std::string_view test_name) {
continue;
}
if (!test_suite.Load()) {
XELOGE("TEST SUITE {} FAILED TO LOAD", xe::path_to_utf8(test_path));
XELOGE("TEST SUITE {} FAILED TO LOAD", test_path);
load_failed = true;
continue;
}

View File

@ -421,8 +421,7 @@ X_STATUS Emulator::MountPath(const std::filesystem::path& path,
return X_STATUS_NO_SUCH_FILE;
}
if (!file_system_->RegisterDevice(std::move(device))) {
XELOGE("Unable to register the input file to {}.",
xe::path_to_utf8(mount_path));
XELOGE("Unable to register the input file to {}.", mount_path);
return X_STATUS_NO_SUCH_FILE;
}
@ -658,8 +657,7 @@ X_STATUS Emulator::DataMigration(const uint64_t xuid) {
if (ec) {
failure_count++;
XELOGW("{}: Moving from: {} to: {} failed! Error message: {} ({:08X})",
__func__, xe::path_to_utf8(previous_path),
xe::path_to_utf8(path / content_type.name), ec.message(),
__func__, previous_path, path / content_type.name, ec.message(),
ec.value());
}
}
@ -681,8 +679,8 @@ X_STATUS Emulator::DataMigration(const uint64_t xuid) {
if (ec) {
failure_count++;
XELOGW("{}: Copying from: {} to: {} failed! Error message: {} ({:08X})",
__func__, xe::path_to_utf8(title.path / title.name / "Headers"),
xe::path_to_utf8(xuid_path), ec.message(), ec.value());
__func__, title.path / title.name / "Headers", xuid_path,
ec.message(), ec.value());
}
const auto header_types =
@ -704,8 +702,8 @@ X_STATUS Emulator::DataMigration(const uint64_t xuid) {
failure_count++;
XELOGW(
"{}: Copying from: {} to: {} failed! Error message: {} ({:08X})",
__func__, xe::path_to_utf8(title.path / title.name / "Headers"),
xe::path_to_utf8(common_path), ec.message(), ec.value());
__func__, title.path / title.name / "Headers", common_path,
ec.message(), ec.value());
}
}
@ -740,8 +738,7 @@ X_STATUS Emulator::DataMigration(const uint64_t xuid) {
if (ec) {
failure_count++;
XELOGW("{}: Moving from: {} to: {} failed! Error message: {} ({:08X})",
__func__, xe::path_to_utf8(path_from),
xe::path_to_utf8(path_to_profile_data / title.name),
__func__, path_from, path_to_profile_data / title.name,
ec.message(), ec.value());
} else {
std::error_code ec;
@ -812,7 +809,7 @@ X_STATUS Emulator::InstallContentPackage(
installation_info.installation_path =
fmt::format("{:016X}/{:08X}/{:08X}/{}", xuid, dev->title_id(),
dev->content_type(), xe::path_to_utf8(path.filename()));
dev->content_type(), path.filename());
installation_info.content_name =
xe::to_utf8(dev->content_header().display_name());
@ -1401,20 +1398,19 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
XELOGI("Loading module {}", module_path);
auto module = kernel_state_->LoadUserModule(module_path);
if (!module) {
XELOGE("Failed to load user module {}", xe::path_to_utf8(path));
XELOGE("Failed to load user module {}", path);
return X_STATUS_NOT_FOUND;
}
X_RESULT result = kernel_state_->ApplyTitleUpdate(module);
if (XFAILED(result)) {
XELOGE("Failed to apply title update! Cannot run module {}",
xe::path_to_utf8(path));
XELOGE("Failed to apply title update! Cannot run module {}", path);
return result;
}
result = kernel_state_->FinishLoadingUserModule(module);
if (XFAILED(result)) {
XELOGE("Failed to initialize user module {}", xe::path_to_utf8(path));
XELOGE("Failed to initialize user module {}", path);
return result;
}
// Grab the current title ID.

View File

@ -244,7 +244,7 @@ void PipelineCache::InitializeShaderStorage(
XELOGE(
"Failed to create the shareable shader storage directory, persistent "
"shader storage will be disabled: {}",
xe::path_to_utf8(shader_storage_shareable_root));
shader_storage_shareable_root);
return;
}
}
@ -267,7 +267,7 @@ void PipelineCache::InitializeShaderStorage(
XELOGE(
"Failed to open the Direct3D 12 pipeline description storage file for "
"writing, persistent shader storage will be disabled: {}",
xe::path_to_utf8(pipeline_storage_file_path));
pipeline_storage_file_path);
return;
}
pipeline_storage_file_flush_needed_ = false;
@ -355,7 +355,7 @@ void PipelineCache::InitializeShaderStorage(
XELOGE(
"Failed to open the guest shader storage file for writing, persistent "
"shader storage will be disabled: {}",
xe::path_to_utf8(shader_storage_file_path));
shader_storage_file_path);
fclose(pipeline_storage_file_);
pipeline_storage_file_ = nullptr;
return;

View File

@ -96,8 +96,7 @@ int shader_compiler_main(const std::vector<std::string>& args) {
auto input_file = filesystem::OpenFile(cvars::shader_input, "rb");
if (!input_file) {
XELOGE("Unable to open input file: {}",
xe::path_to_utf8(cvars::shader_input));
XELOGE("Unable to open input file: {}", cvars::shader_input);
return 1;
}
size_t input_file_size = std::filesystem::file_size(cvars::shader_input);
@ -105,8 +104,7 @@ int shader_compiler_main(const std::vector<std::string>& args) {
fread(ucode_dwords.data(), 4, ucode_dwords.size(), input_file);
fclose(input_file);
XELOGI("Opened {} as a {} shader, {} words ({} bytes).",
xe::path_to_utf8(cvars::shader_input),
XELOGI("Opened {} as a {} shader, {} words ({} bytes).", cvars::shader_input,
shader_type == xenos::ShaderType::kVertex ? "vertex" : "pixel",
ucode_dwords.size(), ucode_dwords.size() * 4);

View File

@ -65,7 +65,7 @@ int TraceDump::Main(const std::vector<std::string>& args) {
// Normalize the path and make absolute.
auto abs_path = std::filesystem::absolute(path);
XELOGI("Loading trace file {}...", xe::path_to_utf8(abs_path));
XELOGI("Loading trace file {}...", abs_path);
if (!Setup()) {
XELOGE("Unable to setup trace dump tool");

View File

@ -55,7 +55,7 @@ bool TraceReader::Open(const std::string_view path) {
return false;
}
XELOGI("Mapped {}b trace from {}", trace_size_, xe::path_to_utf8(path));
XELOGI("Mapped {}b trace from {}", trace_size_, path);
XELOGI(" Version: {}", header->version);
auto commit_str = std::string(header->build_commit_sha,
xe::countof(header->build_commit_sha));

View File

@ -129,12 +129,11 @@ void SDLInputDriver::LoadGameControllerDB() {
if (!std::filesystem::exists(cvars::mappings_file)) {
XELOGW("SDL GameControllerDB: file '{}' does not exist.",
xe::path_to_utf8(cvars::mappings_file));
cvars::mappings_file);
return;
}
XELOGI("SDL GameControllerDB: Loading {}",
xe::path_to_utf8(cvars::mappings_file));
XELOGI("SDL GameControllerDB: Loading {}", cvars::mappings_file);
uint32_t updated_mappings = 0;
uint32_t added_mappings = 0;

View File

@ -263,7 +263,7 @@ bool ProfileManager::MountProfile(const uint64_t xuid) {
XELOGE(
"MountProfile: Unable to mount {} profile; file not found or "
"corrupted.",
xe::path_to_utf8(profile_path));
profile_path);
return false;
}
return kernel_state_->file_system()->RegisterDevice(std::move(device));

View File

@ -44,7 +44,7 @@ void PatchDB::LoadPatches() {
if (!std::regex_match(path_to_utf8(patch_file.name),
patch_filename_regex_)) {
XELOGE("PatchDB: Skipped loading file {} due to incorrect filename",
path_to_utf8(patch_file.name));
patch_file.name);
continue;
}
@ -65,8 +65,7 @@ PatchFileEntry PatchDB::ReadPatchFile(
try {
patch_toml_fields = ParseFile(file_path);
} catch (...) {
XELOGE("PatchDB: Cannot load patch file: {}",
path_to_utf8(file_path.filename()));
XELOGE("PatchDB: Cannot load patch file: {}", file_path.filename());
patch_file.title_id = -1;
return patch_file;
};
@ -76,8 +75,7 @@ PatchFileEntry PatchDB::ReadPatchFile(
auto hashes_node = patch_toml_fields.get("hash");
if (!title_name || !title_id || !hashes_node) {
XELOGE("PatchDB: Cannot load patch file: {}",
path_to_utf8(file_path.filename()));
XELOGE("PatchDB: Cannot load patch file: {}", file_path.filename());
patch_file.title_id = -1;
return patch_file;
}

View File

@ -70,8 +70,7 @@ void PluginLoader::LoadTitleConfig(const uint32_t title_id) {
try {
plugins_config = ParseFile(title_plugins_config);
} catch (...) {
XELOGE("Plugins: Cannot load plugin file {}",
path_to_utf8(title_plugins_config));
XELOGE("Plugins: Cannot load plugin file {}", title_plugins_config);
return;
}
@ -82,8 +81,7 @@ void PluginLoader::LoadTitleConfig(const uint32_t title_id) {
plugins_config.get_as<std::string>("title_id")->get();
if (!plugins_config.contains("plugin")) {
XELOGE("Plugins: Cannot find [[plugin]] table in {}",
path_to_utf8(title_plugins_config));
XELOGE("Plugins: Cannot find [[plugin]] table in {}", title_plugins_config);
return;
}
@ -122,8 +120,7 @@ void PluginLoader::LoadTitleConfig(const uint32_t title_id) {
const std::string file =
fmt::format("plugins\\{:08X}\\plugins.toml", title_id);
XELOGE("Hash error! skipping plugin {} in: {}", entry.name,
path_to_utf8(file));
XELOGE("Hash error! skipping plugin {} in: {}", entry.name, file);
continue;
}

View File

@ -311,7 +311,7 @@ bool ImGuiDrawer::LoadWindowsFont(ImGuiIO& io, ImFontConfig& font_config,
io.Fonts->Build();
// Something went wrong while loading custom font. Probably corrupted.
if (!font->IsLoaded()) {
XELOGE("Failed to load custom font: {}", xe::path_to_utf8(font_path));
XELOGE("Failed to load custom font: {}", font_path);
io.Fonts->Clear();
}
CoTaskMemFree(static_cast<void*>(fonts_dir));

View File

@ -18,8 +18,7 @@ namespace vfs {
std::unique_ptr<Device> XContentContainerDevice::CreateContentDevice(
const std::string_view mount_path, const std::filesystem::path& host_path) {
if (!std::filesystem::exists(host_path)) {
XELOGE("Path to XContent container does not exist: {}",
xe::path_to_utf8(host_path));
XELOGE("Path to XContent container does not exist: {}", host_path);
return nullptr;
}
@ -75,8 +74,7 @@ XContentContainerDevice::~XContentContainerDevice() {}
bool XContentContainerDevice::Initialize() {
if (!std::filesystem::exists(host_path_)) {
XELOGE("Path to XContent container does not exist: {}",
xe::path_to_utf8(host_path_));
XELOGE("Path to XContent container does not exist: {}", host_path_);
return false;
}
@ -84,7 +82,7 @@ bool XContentContainerDevice::Initialize() {
return false;
}
XELOGI("Loading XContent header file: {}", xe::path_to_utf8(host_path_));
XELOGI("Loading XContent header file: {}", host_path_);
auto header_file = xe::filesystem::OpenFile(host_path_, "rb");
if (!header_file) {
XELOGE("Error opening XContent header file.");

View File

@ -34,7 +34,7 @@ SvodContainerDevice::Result SvodContainerDevice::LoadHostFiles(
data_fragment_path += ".data";
if (!std::filesystem::exists(data_fragment_path)) {
XELOGE("STFS container is multi-file, but path {} does not exist.",
xe::path_to_utf8(data_fragment_path));
data_fragment_path);
return Result::kFileMismatch;
}
@ -57,7 +57,7 @@ SvodContainerDevice::Result SvodContainerDevice::LoadHostFiles(
auto path = fragment.path / fragment.name;
auto file = xe::filesystem::OpenFile(path, "rb");
if (!file) {
XELOGI("Failed to map SVOD file {}.", xe::path_to_utf8(path));
XELOGI("Failed to map SVOD file {}.", path);
CloseFiles();
return Result::kReadError;
}

View File

@ -32,7 +32,7 @@ DEFINE_transient_path(dump_path, "",
int vfs_dump_main(const std::vector<std::string>& args) {
if (cvars::source.empty() || cvars::dump_path.empty()) {
XELOGE("Usage: {} [source] [dump_path]", xe::path_to_utf8(args[0]));
XELOGE("Usage: {} [source] [dump_path]", args[0]);
return 1;
}