Skip to content

Commit

Permalink
fixup! Fixed handling of INI files in game root directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC committed Feb 5, 2025
1 parent 990746b commit 8aeb7c3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cleo_plugins/IniFiles/IniFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@
using namespace CLEO;

// In case of naked file names without parent path INI file APIs searchs in Windows directory. Add leading ".\" to prevent that.
#define OPCODE_READ_PARAM_FILEPATH_INI(_varName) OPCODE_READ_PARAM_FILEPATH(_varName); \
if (_varName != nullptr && !std::filesystem::path(_varName).has_parent_path()) { memmove(_buff_##_varName + 2, _buff_##_varName, sizeof(_buff_##_varName) - 2); _buff_##_varName[0] = '.'; _buff_##_varName[1] = '\\'; }
static void fixIniFilepath(char* buff)
{
if (!std::filesystem::path(buff).has_parent_path())
{
std::string filename = buff;
strcpy(buff, ".\\");
strcat(buff, filename.c_str());
}
}

#define OPCODE_READ_PARAM_FILEPATH_INI(_varName) OPCODE_READ_PARAM_FILEPATH(_varName); fixIniFilepath(_buff_##_varName)


class IniFiles
{
Expand Down

0 comments on commit 8aeb7c3

Please sign in to comment.