Unicode path support

This commit is contained in:
Anonymous275
2020-12-26 23:35:43 +02:00
parent ab2a58bf42
commit 9a04665c34
6 changed files with 31 additions and 21 deletions

View File

@@ -187,8 +187,14 @@ void InitLauncher(int argc, char* argv[]) {
CustomPort(argc, argv);
CheckForUpdates(argc, argv, std::string(GetVer()) + GetPatch());
}
inline std::string to_string(const std::wstring& str){
auto loc = std::locale{};
std::vector<char> buf(str.size());
std::use_facet<std::ctype<wchar_t>>(loc).narrow(str.data(), str.data() + str.size(), '?', buf.data());
void PreGame(int argc, char* argv[],const std::string& GamePath){
return std::string(buf.data(), buf.size());
}
void PreGame(const std::string& GamePath){
info("Game Version : " + CheckVer(GamePath));
if(!Dev) {
@@ -196,16 +202,17 @@ void PreGame(int argc, char* argv[],const std::string& GamePath){
//if(fallback)link = "https://backup1.beammp.com/builds/client";
std::string link = "https://beammp.com/builds/client";
try {
if (!fs::exists(GetGamePath() + "mods")) {
fs::create_directory(GetGamePath() + "mods");
if (!fs::exists(GetGamePath() + L"mods")) {
fs::create_directory(GetGamePath() + L"mods");
}
if (!fs::exists(GetGamePath() + "mods/multiplayer")) {
fs::create_directory(GetGamePath() + "mods/multiplayer");
if (!fs::exists(GetGamePath() + L"mods/multiplayer")) {
fs::create_directory(GetGamePath() + L"mods/multiplayer");
}
std::wstring P = GetGamePath() + LR"(mods/multiplayer/BeamMP.zip)";
Download(link, to_string(P), true);
}catch(std::exception&e){
fatal(e.what());
}
Download(link, GetGamePath() + R"(mods/multiplayer/BeamMP.zip)", true);
info("Download Complete!");
}