Skip to content
Permalink
Browse files
Merge pull request #6240 from JosJuice/stream-path-encoding
Don't use wrong encoding for paths when opening streams on Windows
  • Loading branch information
leoetlino committed Dec 7, 2017
2 parents 9d24680 + 9d8a82e commit ecf30cf
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
@@ -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;
@@ -124,7 +124,7 @@ class LinearDiskCache
// 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;
}
@@ -7,7 +7,6 @@

#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <string>
#include <vector>

@@ -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();
}
@@ -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;

@@ -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;
@@ -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;
}

0 comments on commit ecf30cf

Please sign in to comment.