mirror of https://github.com/PCSX2/pcsx2.git
misc-plugins:windows: Fix ini/log path issues
Fixes some issues with opening ini/log files when the path contains characters that are not present in the current codepage for the following plugins: SPU2-X LilyPad cdvdGigaherz Dev9null USBnull FWnull
This commit is contained in:
parent
27d0995a8b
commit
c9dbd4118b
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <PluginCompatibility.h>
|
||||||
//#include "PS2Edefs.h"
|
//#include "PS2Edefs.h"
|
||||||
|
|
||||||
#if !defined(_MSC_VER) || !defined(UNICODE)
|
#if !defined(_MSC_VER) || !defined(UNICODE)
|
||||||
|
@ -65,7 +66,7 @@ struct PluginLog
|
||||||
|
|
||||||
bool Open(std::string logname)
|
bool Open(std::string logname)
|
||||||
{
|
{
|
||||||
LogFile = fopen(logname.c_str(), "w");
|
LogFile = px_fopen(logname, "w");
|
||||||
|
|
||||||
if (LogFile) {
|
if (LogFile) {
|
||||||
setvbuf(LogFile, NULL, _IONBF, 0);
|
setvbuf(LogFile, NULL, _IONBF, 0);
|
||||||
|
@ -161,9 +162,9 @@ struct PluginConf
|
||||||
bool Open(std::string name, FileMode mode = READ_FILE)
|
bool Open(std::string name, FileMode mode = READ_FILE)
|
||||||
{
|
{
|
||||||
if (mode == READ_FILE) {
|
if (mode == READ_FILE) {
|
||||||
ConfFile = fopen(name.c_str(), "r");
|
ConfFile = px_fopen(name, "r");
|
||||||
} else {
|
} else {
|
||||||
ConfFile = fopen(name.c_str(), "w");
|
ConfFile = px_fopen(name, "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfFile == NULL)
|
if (ConfFile == NULL)
|
||||||
|
|
|
@ -339,7 +339,7 @@ void CALLBACK PADsetSettingsDir(const char *dir)
|
||||||
//swprintf_s( iniFile, L"%S", (dir==NULL) ? "inis" : dir );
|
//swprintf_s( iniFile, L"%S", (dir==NULL) ? "inis" : dir );
|
||||||
|
|
||||||
//uint targlen = MultiByteToWideChar(CP_ACP, 0, dir, -1, NULL, 0);
|
//uint targlen = MultiByteToWideChar(CP_ACP, 0, dir, -1, NULL, 0);
|
||||||
MultiByteToWideChar(CP_ACP, 0, dir, -1, iniFile, MAX_PATH * 2);
|
MultiByteToWideChar(CP_UTF8, 0, dir, -1, iniFile, MAX_PATH * 2);
|
||||||
wcscat_s(iniFile, L"/LilyPad.ini");
|
wcscat_s(iniFile, L"/LilyPad.ini");
|
||||||
|
|
||||||
createIniDir = false;
|
createIniDir = false;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <PluginCompatibility.h>
|
||||||
|
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
{
|
{
|
||||||
|
@ -45,7 +46,11 @@ void Settings::TrimWhitespace(std::string &str) const
|
||||||
|
|
||||||
void Settings::Load(const std::string &filename)
|
void Settings::Load(const std::string &filename)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::ifstream file(convert_utf8_to_utf16(filename));
|
||||||
|
#else
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
|
#endif
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -72,7 +77,11 @@ void Settings::Load(const std::string &filename)
|
||||||
|
|
||||||
void Settings::Save(const std::string &filename) const
|
void Settings::Save(const std::string &filename) const
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::ofstream file(convert_utf8_to_utf16(filename), std::ios::trunc);
|
||||||
|
#else
|
||||||
std::ofstream file(filename, std::ios::trunc);
|
std::ofstream file(filename, std::ios::trunc);
|
||||||
|
#endif
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ static wxString CfgFile(L"inis/SPU2-X.ini");
|
||||||
|
|
||||||
void CfgSetSettingsDir(const char *dir)
|
void CfgSetSettingsDir(const char *dir)
|
||||||
{
|
{
|
||||||
CfgFile = Path::Combine((dir == NULL) ? wxString(L"inis") : wxString(dir, wxConvFile), L"SPU2-X.ini");
|
CfgFile = Path::Combine((dir == NULL) ? wxString(L"inis") : wxString::FromUTF8(dir), L"SPU2-X.ini");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue