mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-23 11:15:34 +08:00
make sure mod path, if relative, would be relative to the lib itself + return utf8 string
This commit is contained in:
parent
0e4b6e85e0
commit
2c428e071a
@ -31,9 +31,9 @@ void randombytes(char *buf, size_t size)
|
|||||||
|
|
||||||
std::string get_env_variable(std::string name)
|
std::string get_env_variable(std::string name)
|
||||||
{
|
{
|
||||||
wchar_t env_variable[1024];
|
wchar_t env_variable[1024]{};
|
||||||
DWORD ret = GetEnvironmentVariableW(utf8_decode(name).c_str(), env_variable, _countof(env_variable));
|
DWORD ret = GetEnvironmentVariableW(utf8_decode(name).c_str(), env_variable, _countof(env_variable));
|
||||||
if (ret <= 0) {
|
if (ret <= 0 || !env_variable[0]) {
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ std::string get_full_program_path()
|
|||||||
return env_program_path;
|
return env_program_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string program_path;
|
std::string program_path{};
|
||||||
program_path = get_full_lib_path();
|
program_path = get_full_lib_path();
|
||||||
return program_path.substr(0, program_path.rfind(PATH_SEPARATOR)).append(PATH_SEPARATOR);
|
return program_path.substr(0, program_path.rfind(PATH_SEPARATOR)).append(PATH_SEPARATOR);
|
||||||
}
|
}
|
||||||
|
@ -810,7 +810,6 @@ static std::string get_mod_preview_url(const std::string &previewFileName, const
|
|||||||
|
|
||||||
static void try_parse_mods_file(class Settings *settings_client, Settings *settings_server, nlohmann::json &mod_items, const std::string &mods_folder)
|
static void try_parse_mods_file(class Settings *settings_client, Settings *settings_server, nlohmann::json &mod_items, const std::string &mods_folder)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (auto mod = mod_items.begin(); mod != mod_items.end(); ++mod) {
|
for (auto mod = mod_items.begin(); mod != mod_items.end(); ++mod) {
|
||||||
try {
|
try {
|
||||||
std::string mod_images_fullpath = Local_Storage::get_game_settings_path() + "mod_images" + PATH_SEPARATOR + std::string(mod.key());
|
std::string mod_images_fullpath = Local_Storage::get_game_settings_path() + "mod_images" + PATH_SEPARATOR + std::string(mod.key());
|
||||||
@ -824,7 +823,10 @@ static void try_parse_mods_file(class Settings *settings_client, Settings *setti
|
|||||||
newMod.path = mods_folder + PATH_SEPARATOR + std::string(mod.key());
|
newMod.path = mods_folder + PATH_SEPARATOR + std::string(mod.key());
|
||||||
} else {
|
} else {
|
||||||
// make sure the path is normalized for current OS, and absolute
|
// make sure the path is normalized for current OS, and absolute
|
||||||
newMod.path = std::filesystem::absolute(newMod.path).u8string();
|
newMod.path = common_helpers::to_absolute(
|
||||||
|
newMod.path,
|
||||||
|
get_full_program_path()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
newMod.fileType = k_EWorkshopFileTypeCommunity;
|
newMod.fileType = k_EWorkshopFileTypeCommunity;
|
||||||
|
@ -150,7 +150,7 @@ std::string common_helpers::to_absolute(const std::string &path, const std::stri
|
|||||||
std::filesystem::path(path),
|
std::filesystem::path(path),
|
||||||
base.empty() ? std::filesystem::current_path() : std::filesystem::path(base)
|
base.empty() ? std::filesystem::current_path() : std::filesystem::path(base)
|
||||||
);
|
);
|
||||||
return path_abs.string();
|
return path_abs.u8string();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring common_helpers::to_absolute(const std::wstring &path, const std::wstring &base)
|
std::wstring common_helpers::to_absolute(const std::wstring &path, const std::wstring &base)
|
||||||
|
Loading…
Reference in New Issue
Block a user