mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
Gives ANSI path to curl CURLOPT_CAINFO
This commit is contained in:
parent
2aac46efcc
commit
cd4eed0704
@ -1,4 +1,4 @@
|
|||||||
#include "StrFmt.h"
|
#include "StrFmt.h"
|
||||||
#include "BEType.h"
|
#include "BEType.h"
|
||||||
#include "StrUtil.h"
|
#include "StrUtil.h"
|
||||||
#include "cfmt.h"
|
#include "cfmt.h"
|
||||||
@ -14,6 +14,47 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string wchar_to_utf8(wchar_t *src)
|
||||||
|
{
|
||||||
|
std::string utf8_string;
|
||||||
|
auto tmp_size = WideCharToMultiByte(CP_UTF8, 0, src, -1, nullptr, 0, nullptr, nullptr);
|
||||||
|
utf8_string.resize(tmp_size);
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, src, -1, utf8_string.data(), tmp_size, nullptr, nullptr);
|
||||||
|
return utf8_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string wchar_path_to_ansi_path(const std::wstring& src)
|
||||||
|
{
|
||||||
|
std::wstring buf_short;
|
||||||
|
std::string buf_final;
|
||||||
|
|
||||||
|
// Get the short path from the wide char path(short path should only contain ansi characters)
|
||||||
|
auto tmp_size = GetShortPathNameW(src.data(), nullptr, 0);
|
||||||
|
buf_short.resize(tmp_size);
|
||||||
|
GetShortPathNameW(src.data(), buf_short.data(), tmp_size);
|
||||||
|
|
||||||
|
// Convert wide char to ansi
|
||||||
|
tmp_size = WideCharToMultiByte(CP_ACP, 0, buf_short.data(), -1, nullptr, 0, nullptr, nullptr);
|
||||||
|
buf_final.resize(tmp_size);
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, buf_short.data(), -1, buf_final.data(), tmp_size, nullptr, nullptr);
|
||||||
|
|
||||||
|
return buf_final;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string utf8_path_to_ansi_path(const std::string& src)
|
||||||
|
{
|
||||||
|
std::wstring buf_wide;
|
||||||
|
|
||||||
|
// Converts the utf-8 path to wide char
|
||||||
|
auto tmp_size = MultiByteToWideChar(CP_UTF8, 0, src.c_str(), -1, nullptr, 0);
|
||||||
|
buf_wide.resize(tmp_size);
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, src.c_str(), -1, buf_wide.data(), tmp_size);
|
||||||
|
|
||||||
|
return wchar_path_to_ansi_path(buf_wide);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void fmt_class_string<std::pair<const fmt_type_info*, u64>>::format(std::string& out, u64 arg)
|
void fmt_class_string<std::pair<const fmt_type_info*, u64>>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,12 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string wchar_to_utf8(wchar_t *src);
|
||||||
|
std::string wchar_path_to_ansi_path(const std::wstring& src);
|
||||||
|
std::string utf8_path_to_ansi_path(const std::string& src);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Copy null-terminated string from a std::string or a char array to a char array with truncation
|
// Copy null-terminated string from a std::string or a char array to a char array with truncation
|
||||||
template <typename D, typename T>
|
template <typename D, typename T>
|
||||||
inline void strcpy_trunc(D& dst, const T& src)
|
inline void strcpy_trunc(D& dst, const T& src)
|
||||||
|
@ -655,6 +655,18 @@ std::string Emulator::GetHdd1Dir()
|
|||||||
return fmt::replace_all(g_cfg.vfs.dev_hdd1, "$(EmulatorDir)", GetEmuDir());
|
return fmt::replace_all(g_cfg.vfs.dev_hdd1, "$(EmulatorDir)", GetEmuDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string Emulator::GetExeDir()
|
||||||
|
{
|
||||||
|
wchar_t buffer[32767];
|
||||||
|
GetModuleFileNameW(nullptr, buffer, sizeof(buffer)/2);
|
||||||
|
|
||||||
|
std::string path_to_exe = wchar_to_utf8(buffer);
|
||||||
|
size_t last = path_to_exe.find_last_of("\\");
|
||||||
|
return last == std::string::npos ? std::string("") : path_to_exe.substr(0, last+1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string Emulator::GetSfoDirFromGamePath(const std::string& game_path, const std::string& user, const std::string& title_id)
|
std::string Emulator::GetSfoDirFromGamePath(const std::string& game_path, const std::string& user, const std::string& title_id)
|
||||||
{
|
{
|
||||||
if (fs::is_file(game_path + "/PS3_DISC.SFB"))
|
if (fs::is_file(game_path + "/PS3_DISC.SFB"))
|
||||||
|
@ -179,6 +179,10 @@ private:
|
|||||||
void LimitCacheSize();
|
void LimitCacheSize();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
#ifdef _WIN32
|
||||||
|
static std::string GetExeDir();
|
||||||
|
#endif
|
||||||
|
|
||||||
static std::string GetEmuDir();
|
static std::string GetEmuDir();
|
||||||
static std::string GetHddDir();
|
static std::string GetHddDir();
|
||||||
static std::string GetHdd1Dir();
|
static std::string GetHdd1Dir();
|
||||||
|
@ -2,14 +2,20 @@
|
|||||||
#include "curl_handle.h"
|
#include "curl_handle.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "Utilities/StrUtil.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
curl_handle::curl_handle(QObject* parent) : QObject(parent)
|
curl_handle::curl_handle(QObject* parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_curl = curl_easy_init();
|
m_curl = curl_easy_init();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// This shouldn't be needed on linux
|
// This shouldn't be needed on linux
|
||||||
const std::string path_to_cert = Emulator::GetEmuDir() + "cacert.pem";
|
const std::string path_to_cert = Emulator::GetExeDir() + "cacert.pem";
|
||||||
curl_easy_setopt(m_curl, CURLOPT_CAINFO, path_to_cert.c_str());
|
const std::string ansi_path = utf8_path_to_ansi_path(path_to_cert);
|
||||||
|
|
||||||
|
curl_easy_setopt(m_curl, CURLOPT_CAINFO, ansi_path.data());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user