Consolidate case-sensitive filesystem functions

Descent 3 is case-insensitive. It doesn’t matter if a file is named
“ppics.hog” or “PPPICS.HOG”. Descent 3 will load the file regardless. In
order to accomplish this, Descent 3 has to have special code for
case-sensitive filesystems. That code must take a fake case-insensitive
path and turn it into a real case-sensitive path.

Before this change, there was multiple chunks of code that helped turn
fake case-insensitive paths into real case-sensitive paths. There was
cf_FindRealFileNameCaseInsenstive(), mve_FindMovieFileRealName() and a
chunk of code in open_file_in_directory() that only exists if __LINUX__
is defined. This removes each of those pieces of code and replaces them
with a new cf_LocatePath() function.

Using the new cf_LocatePath() function has two main advantages over the
old way of doing things. First, having a single function is simpler than
having three different pieces of code. Second, the new cf_LocatePath()
function will make it easier to create a future commit. That future
commit will make Descent 3 look for files in more than just the -setdir
directory. Having a single function that’s responsible for determining
the true path of a file will make it much easier to create that future
commit.
This commit is contained in:
Jason Yundt
2024-05-22 07:23:17 -04:00
parent fc5f732347
commit 9d08314986
14 changed files with 124 additions and 211 deletions

View File

@@ -183,8 +183,8 @@ bool mod_LoadModule(module *handle, const std::filesystem::path &imodfilename, i
handle->handle = dlopen(modfilename.u8string().c_str(), f);
if (!handle->handle) {
// ok we couldn't find the given name...try other ways
std::filesystem::path parent_path = modfilename.parent_path();
std::filesystem::path new_filename = cf_FindRealFileNameCaseInsensitive(modfilename.filename(), parent_path);
std::filesystem::path parent_path = modfilename.parent_path().filename();
std::filesystem::path new_filename = cf_LocatePath(parent_path / modfilename.filename());
if (new_filename.empty()) {
LOG_ERROR.printf("Module Load Err: %s", dlerror());