Merge pull request #6240 from JosJuice/stream-path-encoding

Don't use wrong encoding for paths when opening streams on Windows
This commit is contained in:
Leo Lam 2017-12-07 10:04:55 +01:00 committed by GitHub
commit ecf30cfc74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 8 deletions

View File

@ -12,6 +12,7 @@
#include "Common/CPUDetect.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
const char procfile[] = "/proc/cpuinfo";
@ -22,7 +23,8 @@ static std::string GetCPUString()
std::string cpu_string = "Unknown";
std::string line;
std::ifstream file(procfile);
std::ifstream file;
File::OpenFStream(file, procfile, std::ios_base::in);
if (!file)
return cpu_string;

View File

@ -124,7 +124,7 @@ public:
// failed to open file for reading or bad header
// close and recreate file
Close();
m_file.open(filename, ios_base::out | ios_base::trunc | ios_base::binary);
File::OpenFStream(m_file, filename, ios_base::out | ios_base::trunc | ios_base::binary);
WriteHeader();
return 0;
}

View File

@ -7,7 +7,6 @@
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <string>
#include <vector>

View File

@ -400,8 +400,8 @@ void Wiimote::ReadData(const wm_read_data* const rd)
{
// TODO Only read the Mii block parts required
std::ifstream file;
file.open((File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin").c_str(),
std::ios::binary | std::ios::in);
File::OpenFStream(file, (File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/mii.bin").c_str(),
std::ios::binary | std::ios::in);
file.read((char*)m_eeprom + 0x0FCA, 0x02f0);
file.close();
}

View File

@ -58,7 +58,8 @@ MemoryWatcher::~MemoryWatcher()
bool MemoryWatcher::LoadAddresses(const std::string& path)
{
std::ifstream locations(path);
std::ifstream locations;
File::OpenFStream(locations, path, std::ios_base::in);
if (!locations)
return false;

View File

@ -150,7 +150,8 @@ void CRenderFrame::OnDropFiles(wxDropFilesEvent& event)
bool CRenderFrame::IsValidSavestateDropped(const std::string& filepath)
{
const int game_id_length = 6;
std::ifstream file(filepath, std::ios::in | std::ios::binary);
std::ifstream file;
File::OpenFStream(file, filepath, std::ios::in | std::ios::binary);
if (!file)
return false;

View File

@ -21,7 +21,10 @@ FPSCounter::FPSCounter()
void FPSCounter::LogRenderTimeToFile(u64 val)
{
if (!m_bench_file.is_open())
m_bench_file.open(File::GetUserPath(D_LOGS_IDX) + "render_time.txt");
{
File::OpenFStream(m_bench_file, File::GetUserPath(D_LOGS_IDX) + "render_time.txt",
std::ios_base::out);
}
m_bench_file << std::fixed << std::setprecision(8) << (val / 1000.0) << std::endl;
}