From 02988891313c523e2c901478fc3d8f3614a2ee8b Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 15 Jul 2024 14:50:23 +0300 Subject: [PATCH] windows std::filesystem fixes --- src/core/file_sys/fs.cpp | 2 +- src/core/libraries/kernel/file_system.cpp | 6 +++--- src/core/libraries/libc/libc_stdio.cpp | 6 +++--- src/core/libraries/save_data/savedata.cpp | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/file_sys/fs.cpp b/src/core/file_sys/fs.cpp index f009dc2d..8f7ec08b 100644 --- a/src/core/file_sys/fs.cpp +++ b/src/core/file_sys/fs.cpp @@ -74,7 +74,7 @@ std::filesystem::path MntPoints::GetHostPath(const std::string& guest_directory) bool found_match = false; for (const auto& path : std::filesystem::directory_iterator(current_path)) { const auto candidate = path.path().filename(); - const auto filename = Common::ToLower(candidate); + const auto filename = Common::ToLower(candidate.string()); // Check if a filename matches in case insensitive manner. if (filename != part_low) { continue; diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index be173320..f56b05da 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -58,7 +58,7 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) { if (directory) { file->is_directory = true; file->m_guest_name = path; - file->m_host_name = mnt->GetHostPath(file->m_guest_name); + file->m_host_name = mnt->GetHostPath(file->m_guest_name).string(); if (!std::filesystem::is_directory(file->m_host_name)) { // directory doesn't exist h->DeleteHandle(handle); return ORBIS_KERNEL_ERROR_ENOTDIR; @@ -72,7 +72,7 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) { } } else { file->m_guest_name = path; - file->m_host_name = mnt->GetHostPath(file->m_guest_name); + file->m_host_name = mnt->GetHostPath(file->m_guest_name).string(); int e = 0; if (read) { e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read); @@ -174,7 +174,7 @@ int PS4_SYSV_ABI sceKernelUnlink(const char* path) { return SCE_KERNEL_ERROR_EPERM; } - auto* file = h->getFile(host_path); + auto* file = h->getFile(host_path.string()); if (file != nullptr) { file->f.Unlink(); } diff --git a/src/core/libraries/libc/libc_stdio.cpp b/src/core/libraries/libc/libc_stdio.cpp index 72337b83..2b15bd36 100644 --- a/src/core/libraries/libc/libc_stdio.cpp +++ b/src/core/libraries/libc/libc_stdio.cpp @@ -10,12 +10,12 @@ namespace Libraries::LibC { std::FILE* PS4_SYSV_ABI ps4_fopen(const char* filename, const char* mode) { auto* mnt = Common::Singleton::Instance(); - const auto host_path = mnt->GetHostPath(filename); + const auto host_path = mnt->GetHostPath(filename).string(); FILE* f = std::fopen(host_path.c_str(), mode); if (f != nullptr) { - LOG_INFO(Lib_LibC, "fopen = {}", host_path.native()); + LOG_INFO(Lib_LibC, "fopen = {}", host_path); } else { - LOG_INFO(Lib_LibC, "fopen can't open = {}", host_path.native()); + LOG_INFO(Lib_LibC, "fopen can't open = {}", host_path); } return f; } diff --git a/src/core/libraries/save_data/savedata.cpp b/src/core/libraries/save_data/savedata.cpp index 9f3564e8..71828b33 100644 --- a/src/core/libraries/save_data/savedata.cpp +++ b/src/core/libraries/save_data/savedata.cpp @@ -55,7 +55,7 @@ int PS4_SYSV_ABI sceSaveDataCheckBackupData(const OrbisSaveDataCheckBackupData* if (!std::filesystem::exists(mount_dir)) { return ORBIS_SAVE_DATA_ERROR_NOT_FOUND; } - LOG_INFO(Lib_SaveData, "called = {}", mount_dir.native()); + LOG_INFO(Lib_SaveData, "called = {}", mount_dir.string()); return ORBIS_OK; } @@ -396,7 +396,7 @@ int PS4_SYSV_ABI sceSaveDataLoadIcon(const OrbisSaveDataMountPoint* mountPoint, OrbisSaveDataIcon* icon) { auto* mnt = Common::Singleton::Instance(); const auto mount_dir = mnt->GetHostPath(mountPoint->data); - LOG_INFO(Lib_SaveData, "called: dir = {}", mount_dir.native()); + LOG_INFO(Lib_SaveData, "called: dir = {}", mount_dir.string()); if (icon != nullptr) { Common::FS::IOFile file(mount_dir / "save_data.png", Common::FS::FileAccessMode::Read); @@ -534,7 +534,7 @@ int PS4_SYSV_ABI sceSaveDataSaveIcon(const OrbisSaveDataMountPoint* mountPoint, const OrbisSaveDataIcon* icon) { auto* mnt = Common::Singleton::Instance(); const auto mount_dir = mnt->GetHostPath(mountPoint->data); - LOG_INFO(Lib_SaveData, "called = {}", mount_dir.native()); + LOG_INFO(Lib_SaveData, "called = {}", mount_dir.string()); if (icon != nullptr) { Common::FS::IOFile file(mount_dir / "save_data.png", Common::FS::FileAccessMode::Write); @@ -558,7 +558,7 @@ int PS4_SYSV_ABI sceSaveDataSetParam(const OrbisSaveDataMountPoint* mountPoint, size_t paramBufSize) { auto* mnt = Common::Singleton::Instance(); const auto mount_dir = mnt->GetHostPath(mountPoint->data); - LOG_INFO(Lib_SaveData, "called = {}, mountPoint->data = {}", mount_dir.native(), + LOG_INFO(Lib_SaveData, "called = {}, mountPoint->data = {}", mount_dir.string(), mountPoint->data); if (paramBuf != nullptr) {