[go: nahoru, domu]

Skip to content

Commit

Permalink
io/modules: Make modules load the case sensitive file found in fs
Browse files Browse the repository at this point in the history
  • Loading branch information
EXtremeExploit committed Jun 23, 2024
1 parent 30062f3 commit 4abf877
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
6 changes: 6 additions & 0 deletions vita3k/io/src/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ bool find_case_isens_path(IOState &io, VitaIoDevice &device, const fs::path &tra
final_path = system_path.string().substr(0, system_path.string().find(addcont_id)) + addcont_id;
break;
}
case +VitaIoDevice::vs0: {
// This only works if ALL the parent folders of the path are the correct case or are in a case insensitive fs
// Only the file's name is searched for, not the parent folders
final_path = system_path.string().substr(0, system_path.string().find_last_of('/'));
break;
}
default: {
return false;
}
Expand Down
27 changes: 26 additions & 1 deletion vita3k/modules/module_parent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "io/functions.h"
#include "io/io.h"

#include <boost/filesystem/operations.hpp>
#include <modules/module_parent.h>

#include <cpu/functions.h>
Expand Down Expand Up @@ -186,7 +187,31 @@ SceUID load_module(EmuEnvState &emuenv, const std::string &module_path) {
vfs::FileBuffer module_buffer;
bool res;
VitaIoDevice device = device::get_device(module_path);
auto translated_module_path = translate_path(module_path.c_str(), device, emuenv.io.device_paths);
auto device_for_icase = device;
fs::path translated_module_path = translate_path(module_path.c_str(), device, emuenv.io.device_paths);
auto system_path = device::construct_emulated_path(device, translated_module_path, emuenv.pref_path, emuenv.io.redirect_stdio);

if (emuenv.io.case_isens_find_enabled && !fs::exists(system_path)) {
// Attempt a case-insensitive file search.
const auto original_translated_module_path = translated_module_path;
const auto cached_path = find_in_cache(emuenv.io, string_utils::tolower(translated_module_path.string()));
if (!cached_path.empty()) {
translated_module_path = cached_path;
LOG_TRACE("Found cached filepath at {}", translated_module_path);
} else {
const bool path_found = find_case_isens_path(emuenv.io, device_for_icase, translated_module_path, system_path);
translated_module_path = find_in_cache(emuenv.io, string_utils::tolower(system_path.string()));
if (!translated_module_path.empty() && path_found) {
LOG_TRACE("Found file on case-sensitive filesystem at {}", translated_module_path);
translated_module_path = translated_module_path.string().substr(emuenv.pref_path.string().length());
translated_module_path = translated_module_path.string().substr(translated_module_path.string().find('/') + 1);
} else {
LOG_ERROR("Missing file at {} (target path: {})", original_translated_module_path.string(), module_path);
return SCE_ERROR_ERRNO_ENOENT;
}
}
}

if (device == VitaIoDevice::app0)
res = vfs::read_app_file(module_buffer, emuenv.pref_path, emuenv.io.app_path, translated_module_path);
else
Expand Down

0 comments on commit 4abf877

Please sign in to comment.