Kill off some usages of c_str.

Also changes some function params, but this is ok.
Some simplifications were also able to be made (ie. killing off strcmps with ==, etc).
This commit is contained in:
Lioncash 2014-03-12 15:33:41 -04:00
parent dccc6d8b47
commit a82675b7d5
170 changed files with 812 additions and 704 deletions

View File

@ -71,7 +71,7 @@ namespace AudioCommon
{
std::string audio_file_name = File::GetUserPath(D_DUMPAUDIO_IDX) + "audiodump.wav";
File::CreateFullPath(audio_file_name);
mixer->StartLogAudio(audio_file_name.c_str());
mixer->StartLogAudio(audio_file_name);
}
return soundStream;

View File

@ -4,6 +4,8 @@
#pragma once
#include <string>
#include "AudioCommon/WaveFile.h"
#include "Common/StdMutex.h"
@ -57,23 +59,31 @@ public:
// ---------------------
virtual void StartLogAudio(const char *filename) {
if (! m_logAudio) {
virtual void StartLogAudio(const std::string& filename)
{
if (! m_logAudio)
{
m_logAudio = true;
g_wave_writer.Start(filename, GetSampleRate());
g_wave_writer.SetSkipSilence(false);
NOTICE_LOG(DSPHLE, "Starting Audio logging");
} else {
}
else
{
WARN_LOG(DSPHLE, "Audio logging has already been started");
}
}
virtual void StopLogAudio() {
if (m_logAudio) {
virtual void StopLogAudio()
{
if (m_logAudio)
{
m_logAudio = false;
g_wave_writer.Stop();
NOTICE_LOG(DSPHLE, "Stopping Audio logging");
} else {
}
else
{
WARN_LOG(DSPHLE, "Audio logging has already been stopped");
}
}

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include "AudioCommon/WaveFile.h"
#include "Common/Common.h"
#include "Core/ConfigManager.h"
@ -21,7 +23,7 @@ WaveFileWriter::~WaveFileWriter()
Stop();
}
bool WaveFileWriter::Start(const char *filename, unsigned int HLESampleRate)
bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRate)
{
if (!conv_buffer)
conv_buffer = new short[BUF_SIZE];
@ -29,14 +31,14 @@ bool WaveFileWriter::Start(const char *filename, unsigned int HLESampleRate)
// Check if the file is already open
if (file)
{
PanicAlertT("The file %s was already open, the file header will not be written.", filename);
PanicAlertT("The file %s was already open, the file header will not be written.", filename.c_str());
return false;
}
file.Open(filename, "wb");
if (!file)
{
PanicAlertT("The file %s could not be opened for writing. Please check if it's already opened by another program.", filename);
PanicAlertT("The file %s could not be opened for writing. Please check if it's already opened by another program.", filename.c_str());
return false;
}

View File

@ -14,6 +14,7 @@
#pragma once
#include <string>
#include "Common/FileUtil.h"
class WaveFileWriter
@ -31,7 +32,7 @@ public:
WaveFileWriter();
~WaveFileWriter();
bool Start(const char *filename, unsigned int HLESampleRate);
bool Start(const std::string& filename, unsigned int HLESampleRate);
void Stop();
void SetSkipSilence(bool skip) { skip_silence = skip; }

View File

@ -262,7 +262,7 @@ public:
}
}
void DoMarker(const char* prevName, u32 arbitraryNumber = 0x42)
void DoMarker(const std::string& prevName, u32 arbitraryNumber = 0x42)
{
u32 cookie = arbitraryNumber;
Do(cookie);
@ -270,7 +270,7 @@ public:
if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber)
{
PanicAlertT("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...",
prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
prevName.c_str(), cookie, cookie, arbitraryNumber, arbitraryNumber);
mode = PointerWrap::MODE_MEASURE;
}
}

View File

@ -939,12 +939,12 @@ std::string GetThemeDir(const std::string& theme_name)
return dir;
}
bool WriteStringToFile(const std::string &str, const char *filename)
bool WriteStringToFile(const std::string &str, const std::string& filename)
{
return File::IOFile(filename, "wb").WriteBytes(str.data(), str.size());
}
bool ReadFileToString(const char *filename, std::string &str)
bool ReadFileToString(const std::string& filename, std::string &str)
{
File::IOFile file(filename, "rb");
auto const f = file.GetHandle();

View File

@ -143,8 +143,8 @@ std::string GetBundleDirectory();
std::string &GetExeDirectory();
#endif
bool WriteStringToFile(const std::string &str, const char *filename);
bool ReadFileToString(const char *filename, std::string &str);
bool WriteStringToFile(const std::string& str, const std::string& filename);
bool ReadFileToString(const std::string& filename, std::string& str);
// simple wrapper for cstdlib file functions to
// hopefully will make error checking easier

View File

@ -6,6 +6,7 @@
#include <cstring>
#include <fstream>
#include <string>
#include "Common/Common.h"
#include "Common/FileUtil.h"
@ -48,7 +49,7 @@ class LinearDiskCache
{
public:
// return number of read entries
u32 OpenAndRead(const char *filename, LinearDiskCacheReader<K, V> &reader)
u32 OpenAndRead(const std::string& filename, LinearDiskCacheReader<K, V> &reader)
{
using std::ios_base;

View File

@ -33,6 +33,7 @@
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include "Common/Common.h"
#include "Common/FileUtil.h"
@ -188,7 +189,7 @@ static unsigned int write_empty(FILE* file, u64 count)
return 0;
}
bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename)
bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename)
{
u32 sectors_per_fat;
u32 sectors_per_disk;
@ -196,7 +197,8 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename)
// Convert MB to bytes
disk_size *= 1024 * 1024;
if (disk_size < 0x800000 || disk_size > 0x800000000ULL) {
if (disk_size < 0x800000 || disk_size > 0x800000000ULL)
{
ERROR_LOG(COMMON, "Trying to create SD Card image of size %" PRIu64 "MB is out of range (8MB-32GB)", disk_size/(1024*1024));
return false;
}
@ -212,7 +214,7 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename)
FILE* const f = file.GetHandle();
if (!f)
{
ERROR_LOG(COMMON, "Could not create file '%s', aborting...\n", filename);
ERROR_LOG(COMMON, "Could not create file '%s', aborting...\n", filename.c_str());
return false;
}
@ -229,31 +231,51 @@ bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename)
* zero sectors
*/
if (write_sector(f, s_boot_sector)) goto FailWrite;
if (write_sector(f, s_fsinfo_sector)) goto FailWrite;
if (write_sector(f, s_boot_sector))
goto FailWrite;
if (write_sector(f, s_fsinfo_sector))
goto FailWrite;
if (BACKUP_BOOT_SECTOR > 0)
{
if (write_empty(f, BACKUP_BOOT_SECTOR - 2)) goto FailWrite;
if (write_sector(f, s_boot_sector)) goto FailWrite;
if (write_sector(f, s_fsinfo_sector)) goto FailWrite;
if (write_empty(f, RESERVED_SECTORS - 2 - BACKUP_BOOT_SECTOR)) goto FailWrite;
if (write_empty(f, BACKUP_BOOT_SECTOR - 2))
goto FailWrite;
if (write_sector(f, s_boot_sector))
goto FailWrite;
if (write_sector(f, s_fsinfo_sector))
goto FailWrite;
if (write_empty(f, RESERVED_SECTORS - 2 - BACKUP_BOOT_SECTOR))
goto FailWrite;
}
else
{
if (write_empty(f, RESERVED_SECTORS - 2)) goto FailWrite;
}
if (write_sector(f, s_fat_head)) goto FailWrite;
if (write_empty(f, sectors_per_fat-1)) goto FailWrite;
if (write_sector(f, s_fat_head))
goto FailWrite;
if (write_sector(f, s_fat_head)) goto FailWrite;
if (write_empty(f, sectors_per_fat-1)) goto FailWrite;
if (write_empty(f, sectors_per_fat - 1))
goto FailWrite;
if (write_empty(f, sectors_per_disk - RESERVED_SECTORS - 2*sectors_per_fat)) goto FailWrite;
if (write_sector(f, s_fat_head))
goto FailWrite;
if (write_empty(f, sectors_per_fat - 1))
goto FailWrite;
if (write_empty(f, sectors_per_disk - RESERVED_SECTORS - 2*sectors_per_fat))
goto FailWrite;
return true;
FailWrite:
ERROR_LOG(COMMON, "Could not write to '%s', aborting...\n", filename);
if (unlink(filename) < 0)
ERROR_LOG(COMMON, "unlink(%s) failed\n%s", filename, GetLastErrorMsg());
ERROR_LOG(COMMON, "Could not write to '%s', aborting...\n", filename.c_str());
if (unlink(filename.c_str()) < 0)
ERROR_LOG(COMMON, "unlink(%s) failed\n%s", filename.c_str(), GetLastErrorMsg());
return false;
}

View File

@ -4,6 +4,7 @@
#pragma once
#include <string>
#include "Common/CommonTypes.h"
bool SDCardCreate(u64 disk_size /*in MB*/, const char* filename);
bool SDCardCreate(u64 disk_size /*in MB*/, const std::string& filename);

View File

@ -26,10 +26,10 @@
#endif
// faster than sscanf
bool AsciiToHex(const char* _szValue, u32& result)
bool AsciiToHex(const std::string& _szValue, u32& result)
{
char *endptr = nullptr;
const u32 value = strtoul(_szValue, &endptr, 16);
const u32 value = strtoul(_szValue.c_str(), &endptr, 16);
if (!endptr || *endptr)
return false;

View File

@ -76,7 +76,7 @@ static bool TryParse(const std::string &str, N *const output)
}
// TODO: kill this
bool AsciiToHex(const char* _szValue, u32& result);
bool AsciiToHex(const std::string& _szValue, u32& result);
std::string TabsToSpaces(int tab_size, const std::string &in);

View File

@ -39,13 +39,14 @@ void SymbolDB::Index()
}
}
Symbol *SymbolDB::GetSymbolFromName(const char *name)
Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
{
for (auto& func : functions)
{
if (!strcmp(func.second.name.c_str(), name))
if (func.second.name == name)
return &func.second;
}
return nullptr;
}

View File

@ -80,12 +80,13 @@ public:
SymbolDB() {}
virtual ~SymbolDB() {}
virtual Symbol *GetSymbolFromAddr(u32 addr) { return nullptr; }
virtual Symbol *AddFunction(u32 startAddr) { return nullptr;}
virtual Symbol *AddFunction(u32 startAddr) { return nullptr; }
void AddCompleteSymbol(const Symbol &symbol);
Symbol *GetSymbolFromName(const char *name);
Symbol *GetSymbolFromHash(u32 hash) {
Symbol* GetSymbolFromName(const std::string& name);
Symbol* GetSymbolFromHash(u32 hash)
{
XFuncPtrMap::iterator iter = checksumToFunction.find(hash);
if (iter != checksumToFunction.end())
return iter->second;
@ -93,8 +94,8 @@ public:
return nullptr;
}
const XFuncMap &Symbols() const {return functions;}
XFuncMap &AccessSymbols() {return functions;}
const XFuncMap &Symbols() const { return functions; }
XFuncMap &AccessSymbols() { return functions; }
void Clear(const char *prefix = "");
void List();

View File

@ -16,7 +16,7 @@ SysConf::SysConf()
: m_IsValid(false)
{
m_FilenameDefault = File::GetUserPath(F_WIISYSCONF_IDX);
m_IsValid = LoadFromFile(m_FilenameDefault.c_str());
m_IsValid = LoadFromFile(m_FilenameDefault);
}
SysConf::~SysConf()
@ -32,10 +32,11 @@ void SysConf::Clear()
{
for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i)
delete [] i->data;
m_Entries.clear();
}
bool SysConf::LoadFromFile(const char *filename)
bool SysConf::LoadFromFile(const std::string& filename)
{
// Basic check
if (!File::Exists(filename))
@ -55,7 +56,9 @@ bool SysConf::LoadFromFile(const char *filename)
return true;
}
else
{
return false;
}
}
File::IOFile f(filename, "rb");
@ -361,7 +364,7 @@ void SysConf::GenerateSysConf()
m_Filename = m_FilenameDefault;
}
bool SysConf::SaveToFile(const char *filename)
bool SysConf::SaveToFile(const std::string& filename)
{
File::IOFile f(filename, "r+b");
@ -393,7 +396,8 @@ bool SysConf::Save()
{
if (!m_IsValid)
return false;
return SaveToFile(m_Filename.c_str());
return SaveToFile(m_Filename);
}
void SysConf::UpdateLocation()
@ -416,6 +420,6 @@ bool SysConf::Reload()
std::string& filename = m_Filename.empty() ? m_FilenameDefault : m_Filename;
m_IsValid = LoadFromFile(filename.c_str());
m_IsValid = LoadFromFile(filename);
return m_IsValid;
}

View File

@ -163,8 +163,8 @@ public:
}
bool Save();
bool SaveToFile(const char* filename);
bool LoadFromFile(const char* filename);
bool SaveToFile(const std::string& filename);
bool LoadFromFile(const std::string& filename);
bool Reload();
// This function is used when the NAND root is changed
void UpdateLocation();

View File

@ -126,7 +126,7 @@ bool CBoot::LoadMapFromFilename()
{
std::string strMapFilename;
bool found = FindMapFile(&strMapFilename, nullptr);
if (found && g_symbolDB.LoadMap(strMapFilename.c_str()))
if (found && g_symbolDB.LoadMap(strMapFilename))
{
UpdateDebugger_MapLoaded();
return true;
@ -149,7 +149,7 @@ bool CBoot::Load_BS2(const std::string& _rBootROMFilename)
// Load the whole ROM dump
std::string data;
if (!File::ReadFileToString(_rBootROMFilename.c_str(), data))
if (!File::ReadFileToString(_rBootROMFilename, data))
return false;
u32 ipl_hash = HashAdler32((const u8*)data.data(), data.size());
@ -247,7 +247,7 @@ bool CBoot::BootUp()
{
PPCAnalyst::FindFunctions(0x80004000, 0x811fffff, &g_symbolDB);
SignatureDB db;
if (db.Load((File::GetSysDirectory() + TOTALDB).c_str()))
if (db.Load(File::GetSysDirectory() + TOTALDB))
{
db.Apply(&g_symbolDB);
HLE::PatchFunctions();
@ -268,7 +268,7 @@ bool CBoot::BootUp()
// DOL
case SCoreStartupParameter::BOOT_DOL:
{
CDolLoader dolLoader(_StartupPara.m_strFilename.c_str());
CDolLoader dolLoader(_StartupPara.m_strFilename);
// Check if we have gotten a Wii file or not
bool dolWii = dolLoader.IsWii();
if (dolWii != _StartupPara.bWii)
@ -284,7 +284,7 @@ bool CBoot::BootUp()
}
else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
{
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
BS2Success = EmulatedBS2(dolWii);
}
@ -320,7 +320,7 @@ bool CBoot::BootUp()
}
// Check if we have gotten a Wii file or not
bool elfWii = IsElfWii(_StartupPara.m_strFilename.c_str());
bool elfWii = IsElfWii(_StartupPara.m_strFilename);
if (elfWii != _StartupPara.bWii)
{
PanicAlertT("Warning - starting ELF in wrong console mode!");
@ -334,7 +334,7 @@ bool CBoot::BootUp()
}
else if (!VolumeHandler::IsWii() && !_StartupPara.m_strDefaultGCM.empty())
{
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str());
VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM);
BS2Success = EmulatedBS2(elfWii);
}
@ -362,7 +362,7 @@ bool CBoot::BootUp()
else // Poor man's bootup
{
Load_FST(elfWii);
Boot_ELF(_StartupPara.m_strFilename.c_str());
Boot_ELF(_StartupPara.m_strFilename);
}
UpdateDebugger_MapLoaded();
Dolphin_Debugger::AddAutoBreakpoints();
@ -371,7 +371,7 @@ bool CBoot::BootUp()
// Wii WAD
case SCoreStartupParameter::BOOT_WII_NAND:
Boot_WiiWAD(_StartupPara.m_strFilename.c_str());
Boot_WiiWAD(_StartupPara.m_strFilename);
if (LoadMapFromFilename())
HLE::PatchFunctions();

View File

@ -25,7 +25,7 @@ class CBoot
public:
static bool BootUp();
static bool IsElfWii(const char *filename);
static bool IsElfWii(const std::string& filename);
// Tries to find a map file for the current game by looking first in the
// local user directory, then in the shared user directory.
@ -46,8 +46,8 @@ private:
static void UpdateDebugger_MapLoaded(const char* _gameID = nullptr);
static bool LoadMapFromFilename();
static bool Boot_ELF(const char *filename);
static bool Boot_WiiWAD(const char *filename);
static bool Boot_ELF(const std::string& filename);
static bool Boot_WiiWAD(const std::string& filename);
static bool EmulatedBS2_GC();
static bool EmulatedBS2_Wii();

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include "Common/CommonFuncs.h"
#include "Common/FileUtil.h"
@ -14,14 +16,14 @@ CDolLoader::CDolLoader(u8* _pBuffer, u32 _Size)
Initialize(_pBuffer, _Size);
}
CDolLoader::CDolLoader(const char* _szFilename)
CDolLoader::CDolLoader(const std::string& filename)
: m_isWii(false)
{
const u64 size = File::GetSize(_szFilename);
const u64 size = File::GetSize(filename);
u8* const tmpBuffer = new u8[(size_t)size];
{
File::IOFile pStream(_szFilename, "rb");
File::IOFile pStream(filename, "rb");
pStream.ReadBytes(tmpBuffer, (size_t)size);
}

View File

@ -4,12 +4,14 @@
#pragma once
#include <string>
#include "Common/CommonTypes.h"
class CDolLoader
{
public:
CDolLoader(const char* _szFilename);
CDolLoader(const std::string& filename);
CDolLoader(u8* _pBuffer, u32 _Size);
~CDolLoader();

View File

@ -10,7 +10,7 @@
#include "Core/HLE/HLE.h"
#include "Core/PowerPC/PowerPC.h"
bool CBoot::IsElfWii(const char *filename)
bool CBoot::IsElfWii(const std::string& filename)
{
/* We already check if filename existed before we called this function, so
there is no need for another check, just read the file right away */
@ -55,7 +55,7 @@ bool CBoot::IsElfWii(const char *filename)
}
bool CBoot::Boot_ELF(const char *filename)
bool CBoot::Boot_ELF(const std::string& filename)
{
const u64 filesize = File::GetSize(filename);
u8 *mem = new u8[(size_t)filesize];

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <memory>
#include <string>
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
@ -45,9 +46,8 @@ typedef struct {
u32 unknown[6];
} StateFlags;
bool CBoot::Boot_WiiWAD(const char* _pFilename)
bool CBoot::Boot_WiiWAD(const std::string& _pFilename)
{
std::string state_filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_STATE);
if (File::Exists(state_filename))
@ -102,7 +102,7 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename)
}
else
{
pDolLoader.reset(new CDolLoader(pContent->m_Filename.c_str()));
pDolLoader.reset(new CDolLoader(pContent->m_Filename));
}
pDolLoader->Load();
PC = pDolLoader->GetEntryPoint() | 0x80000000;

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <cctype>
#ifdef _WIN32
#include <windows.h>
#include "VideoCommon/EmuWindow.h"
@ -109,15 +111,17 @@ bool PanicAlertToVideo(const char* text, bool yes_no)
return true;
}
void DisplayMessage(const char *message, int time_in_ms)
void DisplayMessage(const std::string& message, int time_in_ms)
{
SCoreStartupParameter& _CoreParameter =
SConfig::GetInstance().m_LocalCoreStartupParameter;
// Actually displaying non-ASCII could cause things to go pear-shaped
for (const char *c = message; *c != '\0'; ++c)
if (*c < ' ')
for (const char& c : message)
{
if (!std::isprint(c))
return;
}
g_video_backend->Video_AddMessage(message, time_in_ms);
@ -575,7 +579,7 @@ void SaveScreenShot()
SetState(CORE_PAUSE);
g_video_backend->Video_Screenshot(GenerateScreenshotName().c_str());
g_video_backend->Video_Screenshot(GenerateScreenshotName());
if (!bPaused)
SetState(CORE_RUN);
@ -716,13 +720,11 @@ void UpdateTitle()
#endif
// This is our final "frame counter" string
std::string SMessage = StringFromFormat("%s | %s",
SSettings.c_str(), SFPS.c_str());
std::string TMessage = StringFromFormat("%s | ", scm_rev_str) +
SMessage;
std::string SMessage = StringFromFormat("%s | %s", SSettings.c_str(), SFPS.c_str());
std::string TMessage = StringFromFormat("%s | %s", scm_rev_str, SMessage.c_str());
// Show message
g_video_backend->UpdateFPSDisplay(SMessage.c_str());
g_video_backend->UpdateFPSDisplay(SMessage);
// Update the audio timestretcher with the current speed
if (soundStream)
@ -734,11 +736,13 @@ void UpdateTitle()
if (_CoreParameter.bRenderToMain &&
SConfig::GetInstance().m_InterfaceStatusbar)
{
Host_UpdateStatusBar(SMessage.c_str());
Host_UpdateStatusBar(SMessage);
Host_UpdateTitle(scm_rev_str);
}
else
Host_UpdateTitle(TMessage.c_str());
{
Host_UpdateTitle(TMessage);
}
}
} // Core

View File

@ -59,12 +59,7 @@ void* GetWindowHandle();
void StartTrace(bool write);
// This displays messages in a user-visible way.
void DisplayMessage(const char *message, int time_in_ms);
inline void DisplayMessage(const std::string &message, int time_in_ms)
{
DisplayMessage(message.c_str(), time_in_ms);
}
void DisplayMessage(const std::string& message, int time_in_ms);
std::string GetStateFileName();
void SetStateFileName(std::string val);

View File

@ -190,14 +190,14 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
}
else if (!strcasecmp(Extension.c_str(), ".elf"))
{
bWii = CBoot::IsElfWii(m_strFilename.c_str());
bWii = CBoot::IsElfWii(m_strFilename);
Region = USA_DIR;
m_BootType = BOOT_ELF;
bNTSC = true;
}
else if (!strcasecmp(Extension.c_str(), ".dol"))
{
CDolLoader dolfile(m_strFilename.c_str());
CDolLoader dolfile(m_strFilename);
bWii = dolfile.IsWii();
Region = USA_DIR;
m_BootType = BOOT_DOL;

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <cinttypes>
#include <string>
#include <vector>
#include "Common/FifoQueue.h"
@ -23,7 +24,7 @@ namespace CoreTiming
struct EventType
{
TimedCallback callback;
const char *name;
std::string name;
};
std::vector<EventType> event_types;
@ -79,7 +80,7 @@ void FreeEvent(Event* ev)
static void EmptyTimedCallback(u64 userdata, int cyclesLate) {}
int RegisterEvent(const char *name, TimedCallback callback)
int RegisterEvent(const std::string& name, TimedCallback callback)
{
EventType type;
type.name = name;
@ -89,9 +90,9 @@ int RegisterEvent(const char *name, TimedCallback callback)
// we want event type names to remain unique so that we can use them for serialization.
for (auto& event_type : event_types)
{
if (!strcmp(name, event_type.name))
if (name == event_type.name)
{
WARN_LOG(POWERPC, "Discarded old event type \"%s\" because a new type with the same name was registered.", name);
WARN_LOG(POWERPC, "Discarded old event type \"%s\" because a new type with the same name was registered.", name.c_str());
// we don't know if someone might be holding on to the type index,
// so we gut the old event type instead of actually removing it.
event_type.name = "_discarded_event";
@ -154,7 +155,7 @@ void EventDoState(PointerWrap &p, BaseEvent* ev)
bool foundMatch = false;
for (unsigned int i = 0; i < event_types.size(); ++i)
{
if (!strcmp(name.c_str(), event_types[i].name))
if (name == event_types[i].name)
{
ev->type = i;
foundMatch = true;
@ -467,11 +468,9 @@ std::string GetScheduledEventsSummary()
if (t >= event_types.size())
PanicAlertT("Invalid event type %i", t);
const char *name = event_types[ptr->type].name;
if (!name)
name = "[unknown]";
const std::string& name = event_types[ptr->type].name;
text += StringFromFormat("%s : %" PRIi64 " %016" PRIx64 "\n", name, ptr->time, ptr->userdata);
text += StringFromFormat("%s : %" PRIi64 " %016" PRIx64 "\n", name.c_str(), ptr->time, ptr->userdata);
ptr = ptr->next;
}
return text;

View File

@ -36,7 +36,7 @@ u64 GetIdleTicks();
void DoState(PointerWrap &p);
// Returns the event_type identifier. if name is not unique, an existing event_type will be discarded.
int RegisterEvent(const char *name, TimedCallback callback);
int RegisterEvent(const std::string& name, TimedCallback callback);
void UnregisterAllEvents();
// userdata MAY NOT CONTAIN POINTERS. userdata might get written and reloaded from disk,

View File

@ -42,6 +42,7 @@ Initial import
#include <fstream>
#include <iostream>
#include <map>
#include <string>
#include "Common/Common.h"
#include "Common/FileUtil.h"
@ -94,7 +95,7 @@ DSPAssembler::~DSPAssembler()
free(gdg_buffer);
}
bool DSPAssembler::Assemble(const char *text, std::vector<u16> &code, std::vector<int> *line_numbers)
bool DSPAssembler::Assemble(const std::string& text, std::vector<u16> &code, std::vector<int> *line_numbers)
{
if (line_numbers)
line_numbers->clear();

View File

@ -73,7 +73,7 @@ public:
// one for each word of code, indicating the source assembler code line number it came from.
// If returns false, call GetErrorString to get some text to present to the user.
bool Assemble(const char *text, std::vector<u16> &code, std::vector<int> *line_numbers = nullptr);
bool Assemble(const std::string& text, std::vector<u16> &code, std::vector<int> *line_numbers = nullptr);
std::string GetErrorString() const { return last_error_str; }
err_t GetError() const { return last_error; }

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <iostream>
#include <string>
#include <vector>
#include "Common/Common.h"
@ -13,7 +14,7 @@
#include "Core/DSP/DSPCodeUtil.h"
#include "Core/DSP/DSPDisassembler.h"
bool Assemble(const char *text, std::vector<u16> &code, bool force)
bool Assemble(const std::string& text, std::vector<u16> &code, bool force)
{
AssemblerSettings settings;
// settings.pc = 0;
@ -194,7 +195,7 @@ void BinaryStringBEToCode(const std::string &str, std::vector<u16> &code)
}
}
bool LoadBinary(const char *filename, std::vector<u16> &code)
bool LoadBinary(const std::string& filename, std::vector<u16> &code)
{
std::string buffer;
if (!File::ReadFileToString(filename, buffer))
@ -204,7 +205,7 @@ bool LoadBinary(const char *filename, std::vector<u16> &code)
return true;
}
bool SaveBinary(const std::vector<u16> &code, const char *filename)
bool SaveBinary(const std::vector<u16> &code, const std::string& filename)
{
std::string buffer;
CodeToBinaryStringBE(code, buffer);

View File

@ -9,7 +9,7 @@
#include "Common/Common.h"
bool Assemble(const char *text, std::vector<u16> &code, bool force = false);
bool Assemble(const std::string& text, std::vector<u16> &code, bool force = false);
bool Disassemble(const std::vector<u16> &code, bool line_numbers, std::string &text);
bool Compare(const std::vector<u16> &code1, const std::vector<u16> &code2);
void GenRandomCode(u32 size, std::vector<u16> &code);
@ -23,5 +23,5 @@ void CodeToBinaryStringBE(const std::vector<u16> &code, std::string &str);
void BinaryStringBEToCode(const std::string &str, std::vector<u16> &code);
// Load code (big endian binary).
bool LoadBinary(const char *filename, std::vector<u16> &code);
bool SaveBinary(const std::vector<u16> &code, const char *filename);
bool LoadBinary(const std::string& filename, std::vector<u16> &code);
bool SaveBinary(const std::vector<u16> &code, const std::string& filename);

View File

@ -44,7 +44,7 @@ bool init_hax = false;
DSPEmitter *dspjit = nullptr;
Common::Event step_event;
static bool LoadRom(const char *fname, int size_in_words, u16 *rom)
static bool LoadRom(const std::string& fname, int size_in_words, u16 *rom)
{
File::IOFile pFile(fname, "rb");
const size_t size_in_bytes = size_in_words * sizeof(u16);
@ -70,12 +70,12 @@ static bool LoadRom(const char *fname, int size_in_words, u16 *rom)
"Use DSPSpy to dump the file from your physical console.\n"
"\n"
"You may use the DSP HLE engine which does not require ROM dumps.\n"
"(Choose it from the \"Audio\" tab of the configuration dialog.)", fname);
"(Choose it from the \"Audio\" tab of the configuration dialog.)", fname.c_str());
return false;
}
// Returns false iff the hash fails and the user hits "Yes"
static bool VerifyRoms(const char *irom_filename, const char *coef_filename)
static bool VerifyRoms(const std::string& irom_filename, const std::string& coef_filename)
{
struct DspRomHashes
{
@ -136,8 +136,7 @@ static void DSPCore_FreeMemoryPages()
g_dsp.irom = g_dsp.iram = g_dsp.dram = g_dsp.coef = nullptr;
}
bool DSPCore_Init(const char *irom_filename, const char *coef_filename,
bool bUsingJIT)
bool DSPCore_Init(const std::string& irom_filename, const std::string& coef_filename, bool bUsingJIT)
{
g_dsp.step_counter = 0;
cyclesLeft = 0;
@ -155,8 +154,8 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename,
// Try to load real ROM contents.
if (!LoadRom(irom_filename, DSP_IROM_SIZE, g_dsp.irom) ||
!LoadRom(coef_filename, DSP_COEF_SIZE, g_dsp.coef) ||
!VerifyRoms(irom_filename, coef_filename))
!LoadRom(coef_filename, DSP_COEF_SIZE, g_dsp.coef) ||
!VerifyRoms(irom_filename, coef_filename))
{
DSPCore_FreeMemoryPages();
return false;

View File

@ -25,6 +25,8 @@
#pragma once
#include <string>
#include "Common/Thread.h"
#include "Core/DSP/DSPBreakpoints.h"
@ -268,8 +270,7 @@ extern DSPEmitter *dspjit;
extern u16 cyclesLeft;
extern bool init_hax;
bool DSPCore_Init(const char *irom_filename, const char *coef_filename,
bool bUsingJIT);
bool DSPCore_Init(const std::string& irom_filename, const std::string& coef_filename, bool bUsingJIT);
void DSPCore_Reset();
void DSPCore_Shutdown(); // Frees all allocated memory.

View File

@ -25,6 +25,7 @@
#include <cstdio>
#include <cstdlib>
#include <string>
#include "Common/Common.h"
#include "Common/FileUtil.h"
@ -333,7 +334,7 @@ bool DSPDisassembler::DisOpcode(const u16 *binbuf, int base_addr, int pass, u16
return true;
}
bool DSPDisassembler::DisFile(const char* name, int base_addr, int pass, std::string &output)
bool DSPDisassembler::DisFile(const std::string& name, int base_addr, int pass, std::string &output)
{
File::IOFile in(name, "rb");
if (!in)

View File

@ -25,6 +25,7 @@
#pragma once
#include <map>
#include <string>
#include <vector>
#include "Common/Common.h"
@ -73,7 +74,7 @@ public:
private:
// Moves PC forward and writes the result to dest.
bool DisFile(const char* name, int base_addr, int pass, std::string &output);
bool DisFile(const std::string& name, int base_addr, int pass, std::string &output);
char* DisParams(const DSPOPCTemplate& opc, u16 op1, u16 op2, char* strbuf);
std::map<u16, int> unk_opcodes;

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <functional>
#include <string>
#include "Common/Common.h"
#include "Common/StringUtil.h"
@ -139,9 +140,9 @@ void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level)
});
}
void PrintDataBuffer(LogTypes::LOG_TYPE type, u8* _pData, size_t _Size, const char* _title)
void PrintDataBuffer(LogTypes::LOG_TYPE type, u8* _pData, size_t _Size, const std::string& _title)
{
GENERIC_LOG(type, LogTypes::LDEBUG, "%s", _title);
GENERIC_LOG(type, LogTypes::LDEBUG, "%s", _title.c_str());
for (u32 j = 0; j < _Size;)
{
std::string hex_line = "";

View File

@ -21,7 +21,7 @@ struct CallstackEntry
bool GetCallstack(std::vector<CallstackEntry> &output);
void PrintCallstack();
void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level);
void PrintDataBuffer(LogTypes::LOG_TYPE _Log, u8* _pData, size_t _Size, const char* _title);
void PrintDataBuffer(LogTypes::LOG_TYPE _Log, u8* _pData, size_t _Size, const std::string& _title);
void AddAutoBreakpoints();

View File

@ -3,16 +3,17 @@
// Refer to the license.txt file included.
#include <cstdio>
#include <string>
#include "Common/Common.h"
#include "Common/FileUtil.h"
#include "Core/Debugger/Dump.h"
CDump::CDump(const char* _szFilename) :
CDump::CDump(const std::string& filename) :
m_pData(nullptr)
{
File::IOFile pStream(_szFilename, "rb");
File::IOFile pStream(filename, "rb");
if (pStream)
{
m_size = (size_t)pStream.GetSize();

View File

@ -8,13 +8,14 @@
//
#pragma once
#include <string>
#include "Common/Common.h"
class CDump
{
public:
CDump(const char* _szFilename);
CDump(const std::string& filename);
~CDump();
int GetNumberOfSteps();

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include "Common/FileUtil.h"
#include "Core/FifoPlayer/FifoDataFile.h"
@ -41,7 +43,7 @@ void FifoDataFile::AddFrame(const FifoFrameInfo &frameInfo)
m_Frames.push_back(frameInfo);
}
bool FifoDataFile::Save(const char *filename)
bool FifoDataFile::Save(const std::string& filename)
{
File::IOFile file;
if (!file.Open(filename, "wb"))

View File

@ -4,6 +4,7 @@
#pragma once
#include <string>
#include <vector>
#include "Common/Common.h"
@ -68,7 +69,7 @@ public:
const FifoFrameInfo &GetFrame(size_t frame) const { return m_Frames[frame]; }
size_t GetFrameCount() { return m_Frames.size(); }
bool Save(const char *filename);
bool Save(const std::string& filename);
static FifoDataFile *Load(const std::string &filename, bool flagsOnly);

View File

@ -73,7 +73,7 @@ bool InstallCodeHandler()
u32 codelist_location = 0x800028B8; // Debugger on location (0x800022A8 = Debugger off, using codehandleronly.bin)
std::string data;
std::string _rCodeHandlerFilename = File::GetSysDirectory() + GECKO_CODE_HANDLER;
if (!File::ReadFileToString(_rCodeHandlerFilename.c_str(), data))
if (!File::ReadFileToString(_rCodeHandlerFilename, data))
{
NOTICE_LOG(ACTIONREPLAY, "Could not enable cheats because codehandler.bin was missing.");
return false;

View File

@ -156,9 +156,10 @@ bool IsEnabled(int flags)
return true;
}
u32 UnPatch(std::string patchName)
u32 UnPatch(const std::string& patchName)
{
Symbol *symbol = g_symbolDB.GetSymbolFromName(patchName.c_str());
Symbol* symbol = g_symbolDB.GetSymbolFromName(patchName);
if (symbol)
{
for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4)
@ -168,6 +169,7 @@ u32 UnPatch(std::string patchName)
}
return symbol->address;
}
return 0;
}

View File

@ -29,7 +29,7 @@ namespace HLE
void PatchFunctions();
void Patch(u32 pc, const char *func_name);
u32 UnPatch(std::string patchName);
u32 UnPatch(const std::string& patchName);
void Execute(u32 _CurrentPC, u32 _Instruction);
u32 GetFunctionIndex(u32 em_address);

View File

@ -71,7 +71,7 @@ void ExecuteDOL(u8* dolFile, u32 fileSize)
g_symbolDB.Clear();
PPCAnalyst::FindFunctions(0x80004000, 0x811fffff, &g_symbolDB);
SignatureDB db;
if (db.Load((File::GetSysDirectory() + TOTALDB).c_str()))
if (db.Load(File::GetSysDirectory() + TOTALDB))
{
db.Apply(&g_symbolDB);
HLE::PatchFunctions();
@ -127,17 +127,17 @@ void ExecuteDOL(u8* dolFile, u32 fileSize)
void LoadDOLFromDisc(std::string dol)
{
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename.c_str());
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename);
DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume);
if (dol.length() > 1 && dol.compare(0, 1, "/") == 0)
dol = dol.substr(1);
u32 fileSize = (u32) pFileSystem->GetFileSize(dol.c_str());
u32 fileSize = (u32) pFileSystem->GetFileSize(dol);
u8* dolFile = new u8[fileSize];
if (fileSize > 0)
{
pFileSystem->ReadFile(dol.c_str(), dolFile, fileSize);
pFileSystem->ReadFile(dol, dolFile, fileSize);
ExecuteDOL(dolFile, fileSize);
}
delete[] dolFile;
@ -145,7 +145,7 @@ void LoadDOLFromDisc(std::string dol)
void LoadBootDOLFromDisc()
{
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename.c_str());
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename);
DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume);
u32 fileSize = pFileSystem->GetBootDOLSize();
u8* dolFile = new u8[fileSize];
@ -159,7 +159,7 @@ void LoadBootDOLFromDisc()
u32 GetDolFileSize(std::string dol)
{
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename.c_str());
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(SConfig::GetInstance().m_LastFilename);
DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume);
std::string dolFile;
@ -169,7 +169,7 @@ u32 GetDolFileSize(std::string dol)
else
dolFile = dol;
return (u32)pFileSystem->GetFileSize(dolFile.c_str());
return (u32)pFileSystem->GetFileSize(dolFile);
}
u16 GetIOSVersion()

View File

@ -143,7 +143,7 @@ bool DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
irom_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_IROM;
if (!File::Exists(coef_file))
coef_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_COEF;
if (!DSPCore_Init(irom_file.c_str(), coef_file.c_str(), AudioCommon::UseJIT()))
if (!DSPCore_Init(irom_file, coef_file, AudioCommon::UseJIT()))
return false;
g_dsp.cpu_ram = Memory::GetPointer(0);

View File

@ -8,9 +8,11 @@
#include <cstdio>
#include <cstdlib>
#include <string>
#include "Common/Common.h"
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "Core/DSP/DSPCodeUtil.h"
#include "Core/DSP/DSPCore.h"
@ -21,10 +23,8 @@
bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc)
{
char binFile[MAX_PATH];
char txtFile[MAX_PATH];
sprintf(binFile, "%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc);
sprintf(txtFile, "%sDSP_UC_%08X.txt", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc);
const std::string binFile = StringFromFormat("%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc);
const std::string txtFile = StringFromFormat("%sDSP_UC_%08X.txt", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc);
File::IOFile pFile(binFile, "wb");
if (pFile)
@ -34,7 +34,7 @@ bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc)
}
else
{
PanicAlert("Can't open file (%s) to dump UCode!!", binFile);
PanicAlert("Can't open file (%s) to dump UCode!!", binFile.c_str());
return false;
}

View File

@ -111,12 +111,12 @@ void DisasssembleRange(u16 start, u16 end)
}
bool ReadAnnotatedAssembly(const char *filename)
bool ReadAnnotatedAssembly(const std::string& filename)
{
File::IOFile f(filename, "r");
if (!f)
{
ERROR_LOG(DSPLLE, "Bah! ReadAnnotatedAssembly couldn't find the file %s", filename);
ERROR_LOG(DSPLLE, "Bah! ReadAnnotatedAssembly couldn't find the file %s", filename.c_str());
return false;
}
char line[512];

View File

@ -4,6 +4,8 @@
#pragma once
#include <string>
#include "Common/Common.h"
#include "Common/SymbolDB.h"
@ -22,7 +24,7 @@ public:
extern DSPSymbolDB g_dsp_symbol_db;
bool ReadAnnotatedAssembly(const char *filename);
bool ReadAnnotatedAssembly(const std::string& filename);
void AutoDisassembly(u16 start_addr, u16 end_addr);
void Clear();

View File

@ -317,15 +317,15 @@ void InsertDiscCallback(u64 userdata, int cyclesLate)
delete _FileName;
}
void ChangeDisc(const char* _newFileName)
void ChangeDisc(const std::string& newFileName)
{
std::string* _FileName = new std::string(_newFileName);
std::string* _FileName = new std::string(newFileName);
CoreTiming::ScheduleEvent_Threadsafe(0, ejectDisc);
CoreTiming::ScheduleEvent_Threadsafe(500000000, insertDisc, (u64)_FileName);
if (Movie::IsRecordingInput())
{
Movie::g_bDiscChange = true;
std::string fileName = _newFileName;
std::string fileName = newFileName;
auto sizeofpath = fileName.find_last_of("/\\") + 1;
if (fileName.substr(sizeofpath).length() > 40)
{

View File

@ -4,6 +4,7 @@
#pragma once
#include <string>
#include "Common/CommonTypes.h"
class PointerWrap;
@ -21,7 +22,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base);
// Disc detection and swapping
void SetDiscInside(bool _DiscInside);
bool IsDiscInside();
void ChangeDisc(const char* _FileName);
void ChangeDisc(const std::string& fileName);
// Lid Functions
void SetLidOpen(bool _bOpen = true);

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <cinttypes>
#include <string>
#include "Common/ColorUtil.h"
#include "Core/HW/GCMemcard.h"
@ -14,7 +15,7 @@ static void ByteSwap(u8 *valueA, u8 *valueB)
*valueB = tmp;
}
GCMemcard::GCMemcard(const char *filename, bool forceCreation, bool sjis)
GCMemcard::GCMemcard(const std::string& filename, bool forceCreation, bool sjis)
: m_valid(false)
, m_fileName(filename)
{
@ -23,7 +24,7 @@ GCMemcard::GCMemcard(const char *filename, bool forceCreation, bool sjis)
File::IOFile mcdFile(m_fileName, "rb");
if (!mcdFile.IsOpen())
{
if (!forceCreation && !AskYesNoT("\"%s\" does not exist.\n Create a new 16MB Memcard?", filename))
if (!forceCreation && !AskYesNoT("\"%s\" does not exist.\n Create a new 16MB Memcard?", filename.c_str()))
{
return;
}
@ -43,12 +44,12 @@ GCMemcard::GCMemcard(const char *filename, bool forceCreation, bool sjis)
auto size = mcdFile.GetSize();
if (size < MC_FST_BLOCKS*BLOCK_SIZE)
{
PanicAlertT("%s failed to load as a memorycard \nfile is not large enough to be a valid memory card file (0x%x bytes)", filename, (unsigned) size);
PanicAlertT("%s failed to load as a memorycard \nfile is not large enough to be a valid memory card file (0x%x bytes)", filename.c_str(), (unsigned) size);
return;
}
if (size % BLOCK_SIZE)
{
PanicAlertT("%s failed to load as a memorycard \n Card file size is invalid (0x%x bytes)", filename, (unsigned) size);
PanicAlertT("%s failed to load as a memorycard \n Card file size is invalid (0x%x bytes)", filename.c_str(), (unsigned) size);
return;
}
@ -63,7 +64,7 @@ GCMemcard::GCMemcard(const char *filename, bool forceCreation, bool sjis)
case MemCard2043Mb:
break;
default:
PanicAlertT("%s failed to load as a memorycard \n Card size is invalid (0x%x bytes)", filename, (unsigned) size);
PanicAlertT("%s failed to load as a memorycard \n Card size is invalid (0x%x bytes)", filename.c_str(), (unsigned) size);
return;
}
}
@ -795,7 +796,7 @@ u32 GCMemcard::CopyFrom(const GCMemcard& source, u8 index)
}
}
u32 GCMemcard::ImportGci(const char *inputFile, const std::string &outputFile)
u32 GCMemcard::ImportGci(const std::string& inputFile, const std::string &outputFile)
{
if (outputFile.empty() && !m_valid)
return OPENFAIL;
@ -809,7 +810,7 @@ u32 GCMemcard::ImportGci(const char *inputFile, const std::string &outputFile)
return result;
}
u32 GCMemcard::ImportGciInternal(FILE* gcih, const char *inputFile, const std::string &outputFile)
u32 GCMemcard::ImportGciInternal(FILE* gcih, const std::string& inputFile, const std::string &outputFile)
{
File::IOFile gci(gcih);
unsigned int offset;
@ -898,30 +899,22 @@ u32 GCMemcard::ImportGciInternal(FILE* gcih, const char *inputFile, const std::s
return ret;
}
u32 GCMemcard::ExportGci(u8 index, const char *fileName, const std::string &directory) const
u32 GCMemcard::ExportGci(u8 index, const std::string& fileName, const std::string &directory) const
{
File::IOFile gci;
int offset = GCI;
if (!fileName)
{
std::string gciFilename;
if (!GCI_FileName(index, gciFilename)) return SUCCESS;
gci.Open(directory + DIR_SEP + gciFilename, "wb");
}
else
{
gci.Open(fileName, "wb");
std::string fileType;
SplitPath(fileName, nullptr, nullptr, &fileType);
if (!strcasecmp(fileType.c_str(), ".gcs"))
{
offset = GCS;
}
else if (!strcasecmp(fileType.c_str(), ".sav"))
{
offset = SAV;
}
gci.Open(fileName, "wb");
std::string fileType;
SplitPath(fileName, nullptr, nullptr, &fileType);
if (!strcasecmp(fileType.c_str(), ".gcs"))
{
offset = GCS;
}
else if (!strcasecmp(fileType.c_str(), ".sav"))
{
offset = SAV;
}
if (!gci)

View File

@ -4,6 +4,8 @@
#pragma once
#include <string>
#include "Common/Common.h"
#include "Common/CommonPaths.h"
#include "Common/StringUtil.h"
@ -169,12 +171,12 @@ private:
};
#pragma pack(pop)
u32 ImportGciInternal(FILE* gcih, const char *inputFile, const std::string &outputFile);
u32 ImportGciInternal(FILE* gcih, const std::string& inputFile, const std::string &outputFile);
static void FormatInternal(GCMC_Header &GCP);
void initDirBatPointers() ;
public:
GCMemcard(const char* fileName, bool forceCreation=false, bool sjis=false);
GCMemcard(const std::string& fileName, bool forceCreation=false, bool sjis=false);
bool IsValid() const { return m_valid; }
bool IsAsciiEncoding() const;
bool Save();
@ -233,10 +235,10 @@ public:
u32 CopyFrom(const GCMemcard& source, u8 index);
// reads a .gci/.gcs/.sav file and calls ImportFile or saves out a gci file
u32 ImportGci(const char* inputFile,const std::string &outputFile);
u32 ImportGci(const std::string& inputFile,const std::string &outputFile);
// writes a .gci file to disk containing index
u32 ExportGci(u8 index, const char* fileName, const std::string &directory) const;
u32 ExportGci(u8 index, const std::string& fileName, const std::string &directory) const;
// GCI files are untouched, SAV files are byteswapped
// GCS files have the block count set, default is 1 (For export as GCS)

View File

@ -4,6 +4,7 @@
#pragma once
#include <string>
// Host - defines an interface for the emulator core to communicate back to the
// OS-specific layer
@ -38,8 +39,8 @@ void Host_UpdateBreakPointView();
void Host_UpdateDisasmDialog();
void Host_UpdateLogDisplay();
void Host_UpdateMainFrame();
void Host_UpdateStatusBar(const char* _pText, int Filed = 0);
void Host_UpdateTitle(const char* title);
void Host_UpdateStatusBar(const std::string& text, int Filed = 0);
void Host_UpdateTitle(const std::string& title);
// TODO (neobrain): Remove these from host!
void* Host_GetInstance();

View File

@ -100,35 +100,35 @@ void Init()
u32 i = 0;
// Build hardware devices
g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_oh1_57e_305(i, std::string("/dev/usb/oh1/57e/305")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_immediate(i, std::string("/dev/stm/immediate")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_eventhook(i, std::string("/dev/stm/eventhook")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_fs(i, std::string("/dev/fs")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_oh1_57e_305(i, "/dev/usb/oh1/57e/305"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_immediate(i, "/dev/stm/immediate"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_eventhook(i, "/dev/stm/eventhook"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_fs(i, "/dev/fs"); i++;
// IOS allows two ES devices at a time
for (u32 j=0; j<ES_MAX_COUNT; j++)
{
g_DeviceMap[i] = es_handles[j] = new CWII_IPC_HLE_Device_es(i, std::string("/dev/es")); i++;
g_DeviceMap[i] = es_handles[j] = new CWII_IPC_HLE_Device_es(i, "/dev/es"); i++;
es_inuse[j] = false;
}
g_DeviceMap[i] = new CWII_IPC_HLE_Device_di(i, std::string("/dev/di")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_kd_request(i, std::string("/dev/net/kd/request")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_kd_time(i, std::string("/dev/net/kd/time")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_ncd_manage(i, std::string("/dev/net/ncd/manage")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_wd_command(i, std::string("/dev/net/wd/command")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_ip_top(i, std::string("/dev/net/ip/top")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_ssl(i, std::string("/dev/net/ssl")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_kbd(i, std::string("/dev/usb/kbd")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_sdio_slot0(i, std::string("/dev/sdio/slot0")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, std::string("/dev/sdio/slot1")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_kd_request(i, "/dev/net/kd/request"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_kd_time(i, "/dev/net/kd/time"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_ncd_manage(i, "/dev/net/ncd/manage"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_wd_command(i, "/dev/net/wd/command"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_ip_top(i, "/dev/net/ip/top"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_net_ssl(i, "/dev/net/ssl"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_kbd(i, "/dev/usb/kbd"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_sdio_slot0(i, "/dev/sdio/slot0"); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, "/dev/sdio/slot1"); i++;
#if defined(__LIBUSB__) || defined(_WIN32)
g_DeviceMap[i] = new CWII_IPC_HLE_Device_hid(i, std::string("/dev/usb/hid")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_hid(i, "/dev/usb/hid"); i++;
#else
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, std::string("/dev/usb/hid")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, "/dev/usb/hid"); i++;
#endif
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, std::string("/dev/usb/oh1")); i++;
g_DeviceMap[i] = new IWII_IPC_HLE_Device(i, std::string("_Unimplemented_Device_")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stub(i, "/dev/usb/oh1"); i++;
g_DeviceMap[i] = new IWII_IPC_HLE_Device(i, "_Unimplemented_Device_"); i++;
enque_reply = CoreTiming::RegisterEvent("IPCReply", EnqueReplyCallback);
}
@ -190,7 +190,7 @@ void SetDefaultContentFile(const std::string& _rFilename)
{
for (const auto& entry : g_DeviceMap)
{
if (entry.second && entry.second->GetDeviceName().find(std::string("/dev/es")) == 0)
if (entry.second && entry.second->GetDeviceName().find("/dev/es") == 0)
{
((CWII_IPC_HLE_Device_es*)entry.second)->LoadWAD(_rFilename);
}
@ -205,7 +205,7 @@ void ES_DIVerify(u8 *_pTMD, u32 _sz)
void SDIO_EventNotify()
{
CWII_IPC_HLE_Device_sdio_slot0 *pDevice =
(CWII_IPC_HLE_Device_sdio_slot0*)GetDeviceByName(std::string("/dev/sdio/slot0"));
(CWII_IPC_HLE_Device_sdio_slot0*)GetDeviceByName("/dev/sdio/slot0");
if (pDevice)
pDevice->EventNotify();
}

View File

@ -922,7 +922,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
}
else
{
pDolLoader.reset(new CDolLoader(pContent->m_Filename.c_str()));
pDolLoader.reset(new CDolLoader(pContent->m_Filename));
}
pDolLoader->Load(); // TODO: Check why sysmenu does not load the DOL correctly
PC = pDolLoader->GetEntryPoint() | 0x80000000;
@ -1111,7 +1111,7 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz)
if (Movie::IsRecordingInput())
{
// TODO: Check for the actual save data
if (File::Exists((savePath + "banner.bin").c_str()))
if (File::Exists(savePath + "banner.bin"))
Movie::g_bClearSave = false;
else
Movie::g_bClearSave = true;
@ -1120,34 +1120,34 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz)
// TODO: Force the game to save to another location, instead of moving the user's save.
if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsStartingFromClearSave())
{
if (File::Exists((savePath + "banner.bin").c_str()))
if (File::Exists(savePath + "banner.bin"))
{
if (File::Exists((savePath + "../backup/").c_str()))
if (File::Exists(savePath + "../backup/"))
{
// The last run of this game must have been to play back a movie, so their save is already backed up.
File::DeleteDirRecursively(savePath.c_str());
File::DeleteDirRecursively(savePath);
}
else
{
#ifdef _WIN32
MoveFile(UTF8ToTStr(savePath).c_str(), UTF8ToTStr(savePath + "../backup/").c_str());
#else
File::CopyDir(savePath.c_str(),(savePath + "../backup/").c_str());
File::DeleteDirRecursively(savePath.c_str());
File::CopyDir(savePath, savePath + "../backup/");
File::DeleteDirRecursively(savePath);
#endif
}
}
}
else if (File::Exists((savePath + "../backup/").c_str()))
else if (File::Exists(savePath + "../backup/"))
{
// Delete the save made by a previous movie, and copy back the user's save.
if (File::Exists((savePath + "banner.bin").c_str()))
if (File::Exists(savePath + "banner.bin"))
File::DeleteDirRecursively(savePath);
#ifdef _WIN32
MoveFile(UTF8ToTStr(savePath + "../backup/").c_str(), UTF8ToTStr(savePath).c_str());
#else
File::CopyDir((savePath + "../backup/").c_str(), savePath.c_str());
File::DeleteDirRecursively((savePath + "../backup/").c_str());
File::CopyDir(savePath + "../backup/", savePath);
File::DeleteDirRecursively(savePath + "../backup/");
#endif
}

View File

@ -35,7 +35,7 @@ bool CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
{
std::string Path = File::GetUserPath(D_WIIUSER_IDX) + "tmp";
File::DeleteDirRecursively(Path);
File::CreateDir(Path.c_str());
File::CreateDir(Path);
}
Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
@ -505,10 +505,11 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p)
if (p.GetMode() == PointerWrap::MODE_READ)
{
File::DeleteDirRecursively(Path);
File::CreateDir(Path.c_str());
File::CreateDir(Path);
//now restore from the stream
while (1) {
while (1)
{
char type = 0;
p.Do(type);
if (!type)
@ -520,7 +521,7 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p)
{
case 'd':
{
File::CreateDir(name.c_str());
File::CreateDir(name);
break;
}
case 'f':
@ -531,7 +532,8 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p)
File::IOFile handle(name, "wb");
char buf[65536];
u32 count = size;
while (count > 65536) {
while (count > 65536)
{
p.DoArray(&buf[0], 65536);
handle.WriteArray(&buf[0], 65536);
count -= 65536;

View File

@ -53,7 +53,7 @@ void CWII_IPC_HLE_Device_sdio_slot0::OpenInternal()
if (!m_Card)
{
WARN_LOG(WII_IPC_SD, "Failed to open SD Card image, trying to create a new 128MB image...");
if (SDCardCreate(128, filename.c_str()))
if (SDCardCreate(128, filename))
{
WARN_LOG(WII_IPC_SD, "Successfully created %s", filename.c_str());
m_Card.Open(filename, "r+b");

View File

@ -435,14 +435,14 @@ bool BeginRecordingInput(int controllers)
if (File::Exists(tmpStateFilename))
File::Delete(tmpStateFilename);
State::SaveAs(tmpStateFilename.c_str());
State::SaveAs(tmpStateFilename);
g_bRecordingFromSaveState = true;
// This is only done here if starting from save state because otherwise we won't have the titleid. Otherwise it's set in WII_IPC_HLE_Device_es.cpp.
// TODO: find a way to GetTitleDataPath() from Movie::Init()
if (Core::g_CoreStartupParameter.bWii)
{
if (File::Exists((Common::GetTitleDataPath(g_titleID) + "banner.bin").c_str()))
if (File::Exists(Common::GetTitleDataPath(g_titleID) + "banner.bin"))
Movie::g_bClearSave = false;
else
Movie::g_bClearSave = true;
@ -711,9 +711,9 @@ void ReadHeader()
memcpy(MD5, tmpHeader.md5, 16);
}
bool PlayInput(const char *filename)
bool PlayInput(const std::string& filename)
{
if (!filename || g_playMode != MODE_NONE)
if (g_playMode != MODE_NONE)
return false;
if (!File::Exists(filename))
@ -753,7 +753,7 @@ bool PlayInput(const char *filename)
// Load savestate (and skip to frame data)
if (tmpHeader.bFromSaveState)
{
const std::string stateFilename = std::string(filename) + ".sav";
const std::string stateFilename = filename + ".sav";
if (File::Exists(stateFilename))
Core::SetStateFileName(stateFilename);
g_bRecordingFromSaveState = true;
@ -782,12 +782,12 @@ void DoState(PointerWrap &p)
// other variables (such as g_totalBytes and g_totalFrames) are set in LoadInput
}
void LoadInput(const char *filename)
void LoadInput(const std::string& filename)
{
File::IOFile t_record;
if (!t_record.Open(filename, "r+b"))
{
PanicAlertT("Failed to read %s", filename);
PanicAlertT("Failed to read %s", filename.c_str());
EndPlayInput(false);
return;
}
@ -796,7 +796,7 @@ void LoadInput(const char *filename)
if (tmpHeader.filetype[0] != 'D' || tmpHeader.filetype[1] != 'T' || tmpHeader.filetype[2] != 'M' || tmpHeader.filetype[3] != 0x1A)
{
PanicAlertT("Savestate movie %s is corrupted, movie recording stopping...", filename);
PanicAlertT("Savestate movie %s is corrupted, movie recording stopping...", filename.c_str());
EndPlayInput(false);
return;
}
@ -1002,7 +1002,7 @@ void PlayController(SPADStatus *PadStatus, int controllerID)
for (int i = 0; i < numPaths; i++)
{
path = SConfig::GetInstance().m_ISOFolder[i];
if (File::Exists((path + '/' + g_discChange.c_str()).c_str()))
if (File::Exists(path + '/' + g_discChange))
{
found = true;
break;
@ -1010,7 +1010,7 @@ void PlayController(SPADStatus *PadStatus, int controllerID)
}
if (found)
{
DVDInterface::ChangeDisc((path + '/' + g_discChange.c_str()).c_str());
DVDInterface::ChangeDisc(path + '/' + g_discChange);
Core::SetState(Core::CORE_RUN);
}
else
@ -1091,7 +1091,7 @@ void EndPlayInput(bool cont)
}
}
void SaveRecording(const char *filename)
void SaveRecording(const std::string& filename)
{
File::IOFile save_record(filename, "wb");
// Create the real header now and write it
@ -1145,15 +1145,14 @@ void SaveRecording(const char *filename)
if (success && g_bRecordingFromSaveState)
{
std::string stateFilename = filename;
stateFilename.append(".sav");
std::string stateFilename = filename + ".sav";
success = File::Copy(tmpStateFilename, stateFilename);
}
if (success)
Core::DisplayMessage(StringFromFormat("DTM %s saved", filename).c_str(), 2000);
Core::DisplayMessage(StringFromFormat("DTM %s saved", filename.c_str()), 2000);
else
Core::DisplayMessage(StringFromFormat("Failed to save %s", filename).c_str(), 2000);
Core::DisplayMessage(StringFromFormat("Failed to save %s", filename.c_str()), 2000);
}
void SetInputManip(ManipFunction func)

View File

@ -18,10 +18,12 @@ struct ReportFeatures;
// Per-(video )Movie actions
namespace Movie {
namespace Movie
{
// Enumerations and structs
enum PlayMode {
enum PlayMode
{
MODE_NONE = 0,
MODE_RECORDING,
MODE_PLAYING
@ -29,7 +31,8 @@ enum PlayMode {
// Gamecube Controller State
#pragma pack(push,1)
struct ControllerState {
struct ControllerState
{
bool Start:1, A:1, B:1, X:1, Y:1, Z:1; // Binary buttons, 6 bits
bool DPadUp:1, DPadDown:1, // Binary D-Pad buttons, 4 bits
DPadLeft:1, DPadRight:1;
@ -66,7 +69,8 @@ extern std::string g_discChange;
extern u32 g_rerecords;
#pragma pack(push,1)
struct DTMHeader {
struct DTMHeader
{
u8 filetype[4]; // Unique Identifier (always "DTM"0x1A)
u8 gameID[6]; // The Game ID
@ -161,13 +165,13 @@ bool BeginRecordingInput(int controllers);
void RecordInput(SPADStatus *PadStatus, int controllerID);
void RecordWiimote(int wiimote, u8 *data, u8 size);
bool PlayInput(const char *filename);
void LoadInput(const char *filename);
bool PlayInput(const std::string& filename);
void LoadInput(const std::string& filename);
void ReadHeader();
void PlayController(SPADStatus *PadStatus, int controllerID);
bool PlayWiimote(int wiimote, u8* data, const struct WiimoteEmu::ReportFeatures& rptf, int irMode);
void EndPlayInput(bool cont);
void SaveRecording(const char *filename);
void SaveRecording(const std::string& filename);
void DoState(PointerWrap &p);
void CheckMD5();
void GetMD5();

View File

@ -47,14 +47,13 @@ std::vector<Patch> onFrame;
std::map<u32, int> speedHacks;
std::vector<std::string> discList;
void LoadPatchSection(const char *section, std::vector<Patch>& patches,
IniFile& globalIni, IniFile& localIni)
void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, IniFile& globalIni, IniFile& localIni)
{
// Load the name of all enabled patches
std::string enabledSectionName = std::string(section) + "_Enabled";
std::string enabledSectionName = section + "_Enabled";
std::vector<std::string> enabledLines;
std::set<std::string> enabledNames;
localIni.GetLines(enabledSectionName.c_str(), enabledLines);
localIni.GetLines(enabledSectionName, enabledLines);
for (const std::string& line : enabledLines)
{
if (line.size() != 0 && line[0] == '$')

View File

@ -4,6 +4,7 @@
#pragma once
#include <string>
#include "Common/IniFile.h"
namespace PatchEngine
@ -36,7 +37,7 @@ struct Patch
};
int GetSpeedhackCycles(const u32 addr);
void LoadPatchSection(const char *section, std::vector<Patch> &patches,
void LoadPatchSection(const std::string& section, std::vector<Patch> &patches,
IniFile &globalIni, IniFile &localIni);
void LoadPatches();
void ApplyFramePatches();

View File

@ -4,6 +4,7 @@
#include <algorithm>
#include <cinttypes>
#include <string>
#ifdef _WIN32
#include <windows.h>
@ -123,7 +124,7 @@ namespace JitInterface
return jit;
}
void WriteProfileResults(const char *filename)
void WriteProfileResults(const std::string& filename)
{
// Can't really do this with no jit core available
#if _M_X86
@ -157,7 +158,7 @@ namespace JitInterface
File::IOFile f(filename, "w");
if (!f)
{
PanicAlert("Failed to open %s", filename);
PanicAlert("Failed to open %s", filename.c_str());
return;
}
fprintf(f.GetHandle(), "origAddr\tblkName\tcost\ttimeCost\tpercent\ttimePercent\tOvAllinBlkTime(ms)\tblkCodeSize\n");

View File

@ -4,6 +4,7 @@
#pragma once
#include <string>
#include "Common/ChunkFile.h"
#include "Core/PowerPC/CPUCoreBase.h"
@ -16,7 +17,7 @@ namespace JitInterface
CPUCoreBase *GetCore();
// Debugging
void WriteProfileResults(const char *filename);
void WriteProfileResults(const std::string& filename);
// Memory Utilities
bool IsInCodeSpace(u8 *ptr);

View File

@ -55,7 +55,7 @@ Symbol *PPCSymbolDB::AddFunction(u32 startAddr)
}
}
void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const char *name, int type)
void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& name, int type)
{
XFuncMap::iterator iter = functions.find(startAddr);
if (iter != functions.end())
@ -196,7 +196,7 @@ void PPCSymbolDB::LogFunctionCall(u32 addr)
// This one can load both leftover map files on game discs (like Zelda), and mapfiles
// produced by SaveSymbolMap below.
bool PPCSymbolDB::LoadMap(const char *filename)
bool PPCSymbolDB::LoadMap(const std::string& filename)
{
File::IOFile f(filename, "r");
if (!f)
@ -263,11 +263,12 @@ bool PPCSymbolDB::LoadMap(const char *filename)
// ===================================================
/* Save the map file and save a code file */
// ----------------
bool PPCSymbolDB::SaveMap(const char *filename, bool WithCodes) const
bool PPCSymbolDB::SaveMap(const std::string& filename, bool WithCodes) const
{
// Format the name for the codes version
std::string mapFile = filename;
if (WithCodes) mapFile = mapFile.substr(0, mapFile.find_last_of(".")) + "_code.map";
if (WithCodes)
mapFile = mapFile.substr(0, mapFile.find_last_of(".")) + "_code.map";
// Check size
const int wxYES_NO = 0x00000002 | 0x00000008;
@ -277,7 +278,9 @@ bool PPCSymbolDB::SaveMap(const char *filename, bool WithCodes) const
"No symbol names are generated. Do you want to replace '%s' with a blank file?",
mapFile.c_str()).c_str(), "Confirm", wxYES_NO)) return false;
}
if (WithCodes) Host_UpdateStatusBar("Saving code, please stand by ...");
if (WithCodes)
Host_UpdateStatusBar("Saving code, please stand by ...");
// Make a file
File::IOFile f(mapFile, "w");

View File

@ -26,7 +26,7 @@ public:
~PPCSymbolDB();
Symbol *AddFunction(u32 startAddr) override;
void AddKnownSymbol(u32 startAddr, u32 size, const char *name, int type = Symbol::SYMBOL_FUNCTION);
void AddKnownSymbol(u32 startAddr, u32 size, const std::string& name, int type = Symbol::SYMBOL_FUNCTION);
Symbol *GetSymbolFromAddr(u32 addr) override;
@ -34,8 +34,8 @@ public:
void FillInCallers();
bool LoadMap(const char *filename);
bool SaveMap(const char *filename, bool WithCodes = false) const;
bool LoadMap(const std::string& filename);
bool SaveMap(const std::string& filename, bool WithCodes = false) const;
void PrintCalls(u32 funcAddr) const;
void PrintCallers(u32 funcAddr) const;

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include "Core/PowerPC/JitInterface.h"
namespace Profiler
@ -10,7 +11,7 @@ namespace Profiler
bool g_ProfileBlocks;
bool g_ProfileInstructions;
void WriteProfileResults(const char *filename)
void WriteProfileResults(const std::string& filename)
{
JitInterface::WriteProfileResults(filename);
}

View File

@ -5,6 +5,8 @@
#pragma once
#include <string>
#ifdef _WIN32
#if _M_X86_32
@ -58,5 +60,5 @@ namespace Profiler
extern bool g_ProfileBlocks;
extern bool g_ProfileInstructions;
void WriteProfileResults(const char *filename);
void WriteProfileResults(const std::string& filename);
}

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include "Common/Common.h"
#include "Common/FileUtil.h"
@ -11,7 +13,8 @@
#include "Core/PowerPC/PPCSymbolDB.h"
#include "Core/PowerPC/SignatureDB.h"
namespace {
namespace
{
// On-disk format for SignatureDB entries.
struct FuncDesc
@ -23,7 +26,7 @@ struct FuncDesc
} // namespace
bool SignatureDB::Load(const char *filename)
bool SignatureDB::Load(const std::string& filename)
{
File::IOFile f(filename, "rb");
if (!f)
@ -47,7 +50,7 @@ bool SignatureDB::Load(const char *filename)
return true;
}
bool SignatureDB::Save(const char *filename)
bool SignatureDB::Save(const std::string& filename)
{
File::IOFile f(filename, "wb");
if (!f)
@ -72,7 +75,7 @@ bool SignatureDB::Save(const char *filename)
}
//Adds a known function to the hash database
u32 SignatureDB::Add(u32 startAddr, u32 size, const char *name)
u32 SignatureDB::Add(u32 startAddr, u32 size, const std::string& name)
{
u32 hash = ComputeCodeChecksum(startAddr, startAddr + size);
@ -83,6 +86,7 @@ u32 SignatureDB::Add(u32 startAddr, u32 size, const char *name)
FuncDB::iterator iter = database.find(hash);
if (iter == database.end())
database[hash] = temp_dbfunc;
return hash;
}
@ -126,12 +130,11 @@ void SignatureDB::Apply(PPCSymbolDB *symbol_db)
symbol_db->Index();
}
void SignatureDB::Initialize(PPCSymbolDB *symbol_db, const char *prefix)
void SignatureDB::Initialize(PPCSymbolDB *symbol_db, const std::string& prefix)
{
std::string prefix_str(prefix);
for (const auto& symbol : symbol_db->Symbols())
{
if ((symbol.second.name.substr(0, prefix_str.size()) == prefix_str) || prefix_str.empty())
if ((symbol.second.name.substr(0, prefix.size()) == prefix) || prefix.empty())
{
DBFunc temp_dbfunc;
temp_dbfunc.name = symbol.second.name;

View File

@ -31,15 +31,15 @@ class SignatureDB
public:
// Returns the hash.
u32 Add(u32 startAddr, u32 size, const char *name);
u32 Add(u32 startAddr, u32 size, const std::string& name);
bool Load(const char *filename); // Does not clear. Remember to clear first if that's what you want.
bool Save(const char *filename);
bool Load(const std::string& filename); // Does not clear. Remember to clear first if that's what you want.
bool Save(const std::string& filename);
void Clean(const char *prefix);
void Clear();
void List();
void Initialize(PPCSymbolDB *func_db, const char *prefix = "");
void Initialize(PPCSymbolDB *func_db, const std::string& prefix = "");
void Apply(PPCSymbolDB *func_db);
static u32 ComputeCodeChecksum(u32 offsetStart, u32 offsetEnd);

View File

@ -235,7 +235,7 @@ void CompressAndDumpState(CompressAndDumpState_args save_args)
}
if ((Movie::IsRecordingInput() || Movie::IsPlayingInput()) && !Movie::IsJustStartingRecordingInputFromSaveState())
Movie::SaveRecording((filename + ".dtm").c_str());
Movie::SaveRecording(filename + ".dtm");
else if (!Movie::IsRecordingInput() && !Movie::IsPlayingInput())
File::Delete(filename + ".dtm");
@ -290,8 +290,7 @@ void CompressAndDumpState(CompressAndDumpState_args save_args)
f.WriteBytes(buffer_data, buffer_size);
}
Core::DisplayMessage(StringFromFormat("Saved State to %s",
filename.c_str()).c_str(), 2000);
Core::DisplayMessage(StringFromFormat("Saved State to %s", filename.c_str()), 2000);
g_compressAndDumpStateSyncEvent.Set();
}
@ -444,7 +443,7 @@ void LoadAs(const std::string& filename)
std::lock_guard<std::mutex> lk(g_cs_undo_load_buffer);
SaveToBuffer(g_undo_load_buffer);
if (Movie::IsRecordingInput() || Movie::IsPlayingInput())
Movie::SaveRecording((File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm").c_str());
Movie::SaveRecording(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm");
else if (File::Exists(File::GetUserPath(D_STATESAVES_IDX) +"undo.dtm"))
File::Delete(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm");
}
@ -471,9 +470,9 @@ void LoadAs(const std::string& filename)
{
if (loadedSuccessfully)
{
Core::DisplayMessage(StringFromFormat("Loaded state from %s", filename.c_str()).c_str(), 2000);
Core::DisplayMessage(StringFromFormat("Loaded state from %s", filename.c_str()), 2000);
if (File::Exists(filename + ".dtm"))
Movie::LoadInput((filename + ".dtm").c_str());
Movie::LoadInput(filename + ".dtm");
else if (!Movie::IsJustStartingRecordingInputFromSaveState() && !Movie::IsJustStartingPlayingInputFromSaveState())
Movie::EndPlayInput(false);
}
@ -522,7 +521,7 @@ void VerifyAt(const std::string& filename)
DoState(p);
if (p.GetMode() == PointerWrap::MODE_VERIFY)
Core::DisplayMessage(StringFromFormat("Verified state at %s", filename.c_str()).c_str(), 2000);
Core::DisplayMessage(StringFromFormat("Verified state at %s", filename.c_str()), 2000);
else
Core::DisplayMessage("Unable to Verify : Can't verify state from other revisions !", 4000);
}
@ -623,7 +622,7 @@ void UndoLoadState()
{
LoadFromBuffer(g_undo_load_buffer);
if (Movie::IsRecordingInput() || Movie::IsPlayingInput())
Movie::LoadInput((File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm").c_str());
Movie::LoadInput(File::GetUserPath(D_STATESAVES_IDX) + "undo.dtm");
}
else
{
@ -639,7 +638,7 @@ void UndoLoadState()
// Load the state that the last save state overwritten on
void UndoSaveState()
{
LoadAs((File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav").c_str());
LoadAs(File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav");
}
} // namespace State

View File

@ -33,7 +33,8 @@ void SectorReader::SetSectorSize(int blocksize)
m_blocksize = blocksize;
}
SectorReader::~SectorReader() {
SectorReader::~SectorReader()
{
for (u8*& block : cache)
{
delete [] block;
@ -100,6 +101,7 @@ bool SectorReader::Read(u64 offset, u64 size, u8* out_ptr)
block++;
}
}
return true;
}
@ -112,12 +114,13 @@ bool SectorReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *
return false;
memcpy(out_ptr + i * m_blocksize, data, m_blocksize);
}
return true;
}
IBlobReader* CreateBlobReader(const char* filename)
IBlobReader* CreateBlobReader(const std::string& filename)
{
if (cdio_is_cdrom(std::string(filename)))
if (cdio_is_cdrom(filename))
return DriveReader::Create(filename);
if (!File::Exists(filename))

View File

@ -14,6 +14,7 @@
// detect whether the file is a compressed blob, or just a big hunk of data, or a drive, and
// automatically do the right thing.
#include <string>
#include "Common/CommonTypes.h"
namespace DiscIO
@ -63,13 +64,13 @@ public:
};
// Factory function - examines the path to choose the right type of IBlobReader, and returns one.
IBlobReader* CreateBlobReader(const char *filename);
IBlobReader* CreateBlobReader(const std::string& filename);
typedef void (*CompressCB)(const char *text, float percent, void* arg);
bool CompressFileToBlob(const char *infile, const char *outfile, u32 sub_type = 0, int sector_size = 16384,
bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u32 sub_type = 0, int sector_size = 16384,
CompressCB callback = nullptr, void *arg = nullptr);
bool DecompressBlobToFile(const char *infile, const char *outfile,
bool DecompressBlobToFile(const std::string& infile, const std::string& outfile,
CompressCB callback = nullptr, void *arg = nullptr);
} // namespace

View File

@ -29,7 +29,7 @@ CISOFileReader::CISOFileReader(std::FILE* file)
m_ciso_map[idx] = (1 == header.map[idx]) ? count++ : UNUSED_BLOCK_ID;
}
CISOFileReader* CISOFileReader::Create(const char* filename)
CISOFileReader* CISOFileReader::Create(const std::string& filename)
{
if (IsCISOBlob(filename))
{
@ -37,7 +37,9 @@ CISOFileReader* CISOFileReader::Create(const char* filename)
return new CISOFileReader(f.ReleaseHandle());
}
else
{
return nullptr;
}
}
u64 CISOFileReader::GetDataSize() const
@ -79,7 +81,7 @@ bool CISOFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
return true;
}
bool IsCISOBlob(const char* filename)
bool IsCISOBlob(const std::string& filename)
{
File::IOFile f(filename, "rb");

View File

@ -5,6 +5,7 @@
#pragma once
#include <cstdio>
#include <string>
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
@ -13,7 +14,7 @@
namespace DiscIO
{
bool IsCISOBlob(const char* filename);
bool IsCISOBlob(const std::string& filename);
static const u32 CISO_HEADER_SIZE = 0x8000;
static const u32 CISO_MAP_SIZE = CISO_HEADER_SIZE - sizeof(u32) - sizeof(char) * 4;
@ -33,7 +34,7 @@ struct CISOHeader
class CISOFileReader : public IBlobReader
{
public:
static CISOFileReader* Create(const char* filename);
static CISOFileReader* Create(const std::string& filename);
u64 GetDataSize() const override;
u64 GetRawSize() const override;

View File

@ -25,7 +25,7 @@
namespace DiscIO
{
CompressedBlobReader::CompressedBlobReader(const char *filename) : file_name(filename)
CompressedBlobReader::CompressedBlobReader(const std::string& filename) : file_name(filename)
{
m_file.Open(filename, "rb");
file_size = File::GetSize(filename);
@ -50,7 +50,7 @@ CompressedBlobReader::CompressedBlobReader(const char *filename) : file_name(fil
memset(zlib_buffer, 0, zlib_buffer_size);
}
CompressedBlobReader* CompressedBlobReader::Create(const char* filename)
CompressedBlobReader* CompressedBlobReader::Create(const std::string& filename)
{
if (IsCompressedBlob(filename))
return new CompressedBlobReader(filename);
@ -107,7 +107,7 @@ void CompressedBlobReader::GetBlock(u64 block_num, u8 *out_ptr)
PanicAlert("Hash of block %" PRIu64 " is %08x instead of %08x.\n"
"Your ISO, %s, is corrupt.",
block_num, block_hash, hashes[block_num],
file_name.c_str());
file_name.c_str());
if (uncompressed)
{
@ -140,14 +140,14 @@ void CompressedBlobReader::GetBlock(u64 block_num, u8 *out_ptr)
}
}
bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type,
bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u32 sub_type,
int block_size, CompressCB callback, void* arg)
{
bool scrubbing = false;
if (IsCompressedBlob(infile))
{
PanicAlertT("%s is already compressed! Cannot compress it further.", infile);
PanicAlertT("%s is already compressed! Cannot compress it further.", infile.c_str());
return false;
}
@ -155,7 +155,7 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type,
{
if (!DiscScrubber::SetupScrub(infile, block_size))
{
PanicAlertT("%s failed to be scrubbed. Probably the image is corrupt.", infile);
PanicAlertT("%s failed to be scrubbed. Probably the image is corrupt.", infile.c_str());
return false;
}
@ -278,7 +278,7 @@ cleanup:
return true;
}
bool DecompressBlobToFile(const char* infile, const char* outfile, CompressCB callback, void* arg)
bool DecompressBlobToFile(const std::string& infile, const std::string& outfile, CompressCB callback, void* arg)
{
if (!IsCompressedBlob(infile))
{
@ -320,7 +320,7 @@ bool DecompressBlobToFile(const char* infile, const char* outfile, CompressCB ca
return true;
}
bool IsCompressedBlob(const char* filename)
bool IsCompressedBlob(const std::string& filename)
{
File::IOFile f(filename, "rb");

View File

@ -23,7 +23,7 @@
namespace DiscIO
{
bool IsCompressedBlob(const char* filename);
bool IsCompressedBlob(const std::string& filename);
const u32 kBlobCookie = 0xB10BC001;
@ -46,23 +46,23 @@ struct CompressedBlobHeader // 32 bytes
class CompressedBlobReader : public SectorReader
{
public:
static CompressedBlobReader* Create(const char *filename);
static CompressedBlobReader* Create(const std::string& filename);
~CompressedBlobReader();
const CompressedBlobHeader &GetHeader() const { return header; }
u64 GetDataSize() const override { return header.data_size; }
u64 GetRawSize() const override { return file_size; }
u64 GetBlockCompressedSize(u64 block_num) const;
void GetBlock(u64 block_num, u8 *out_ptr) override;
void GetBlock(u64 block_num, u8* out_ptr) override;
private:
CompressedBlobReader(const char *filename);
CompressedBlobReader(const std::string& filename);
CompressedBlobHeader header;
u64 *block_pointers;
u32 *hashes;
u64* block_pointers;
u32* hashes;
int data_offset;
File::IOFile m_file;
u64 file_size;
u8 *zlib_buffer;
u8* zlib_buffer;
int zlib_buffer_size;
std::string file_name;
};

View File

@ -81,10 +81,10 @@ bool ParsePartitionData(SPartition& _rPartition);
u32 GetDOLSize(u64 _DOLOffset);
bool SetupScrub(const char* filename, int block_size)
bool SetupScrub(const std::string& filename, int block_size)
{
bool success = true;
m_Filename = std::string(filename);
m_Filename = filename;
m_BlockSize = block_size;
if (CLUSTER_SIZE % m_BlockSize != 0)
@ -102,7 +102,7 @@ bool SetupScrub(const char* filename, int block_size)
// Warn if not DVD5 or DVD9 size
if (numClusters != 0x23048 && numClusters != 0x46090)
WARN_LOG(DISCIO, "%s is not a standard sized Wii disc! (%x blocks)", filename, numClusters);
WARN_LOG(DISCIO, "%s is not a standard sized Wii disc! (%x blocks)", filename.c_str(), numClusters);
// Table of free blocks
m_FreeTable = new u8[numClusters];

View File

@ -13,6 +13,7 @@
#pragma once
#include <string>
#include "Common/CommonTypes.h"
namespace File { class IOFile; }
@ -23,7 +24,7 @@ namespace DiscIO
namespace DiscScrubber
{
bool SetupScrub(const char* filename, int block_size);
bool SetupScrub(const std::string& filename, int block_size);
void GetNextBlock(File::IOFile& in, u8* buffer);
void Cleanup();

View File

@ -4,6 +4,7 @@
#include <cstdio>
#include <cstring>
#include <string>
#include "Common/Common.h"
#include "Common/FileUtil.h"
@ -17,7 +18,7 @@
namespace DiscIO
{
DriveReader::DriveReader(const char *drive)
DriveReader::DriveReader(const std::string& drive)
{
#ifdef _WIN32
SectorReader::SetSectorSize(2048);
@ -56,8 +57,10 @@ DriveReader::DriveReader(const char *drive)
#endif
}
else
NOTICE_LOG(DISCIO, "Load from DVD backup failed or no disc in drive %s", drive);
} // DriveReader::DriveReader
{
NOTICE_LOG(DISCIO, "Load from DVD backup failed or no disc in drive %s", drive.c_str());
}
}
DriveReader::~DriveReader()
{
@ -79,18 +82,20 @@ DriveReader::~DriveReader()
#endif
}
DriveReader *DriveReader::Create(const char *drive)
DriveReader* DriveReader::Create(const std::string& drive)
{
DriveReader *reader = new DriveReader(drive);
DriveReader* reader = new DriveReader(drive);
if (!reader->IsOK())
{
delete reader;
return nullptr;
}
return reader;
}
void DriveReader::GetBlock(u64 block_num, u8 *out_ptr)
void DriveReader::GetBlock(u64 block_num, u8* out_ptr)
{
u8* const lpSector = new u8[m_blocksize];
#ifdef _WIN32
@ -109,7 +114,7 @@ void DriveReader::GetBlock(u64 block_num, u8 *out_ptr)
delete[] lpSector;
}
bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8 *out_ptr)
bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8* out_ptr)
{
#ifdef _WIN32
u32 NotUsed;

View File

@ -4,6 +4,8 @@
#pragma once
#include <string>
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "DiscIO/Blob.h"
@ -19,7 +21,7 @@ namespace DiscIO
class DriveReader : public SectorReader
{
private:
DriveReader(const char *drive);
DriveReader(const std::string& drive);
void GetBlock(u64 block_num, u8 *out_ptr) override;
#ifdef _WIN32
@ -33,7 +35,7 @@ private:
s64 size;
public:
static DriveReader *Create(const char *drive);
static DriveReader* Create(const std::string& drive);
~DriveReader();
u64 GetDataSize() const override { return size; }
u64 GetRawSize() const override { return size; }

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include "DiscIO/FileBlob.h"
namespace DiscIO
@ -13,7 +14,7 @@ PlainFileReader::PlainFileReader(std::FILE* file)
m_size = m_file.GetSize();
}
PlainFileReader* PlainFileReader::Create(const char* filename)
PlainFileReader* PlainFileReader::Create(const std::string& filename)
{
File::IOFile f(filename, "rb");
if (f)

View File

@ -5,6 +5,7 @@
#pragma once
#include <cstdio>
#include <string>
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
@ -21,7 +22,7 @@ class PlainFileReader : public IBlobReader
s64 m_size;
public:
static PlainFileReader* Create(const char* filename);
static PlainFileReader* Create(const std::string& filename);
u64 GetDataSize() const override { return m_size; }
u64 GetRawSize() const override { return m_size; }

View File

@ -33,7 +33,7 @@ CFileSystemGCWii::~CFileSystemGCWii()
m_FileInfoVector.clear();
}
u64 CFileSystemGCWii::GetFileSize(const char* _rFullPath)
u64 CFileSystemGCWii::GetFileSize(const std::string& _rFullPath)
{
if (!m_Initialized)
InitFileSystem();
@ -63,7 +63,7 @@ const char* CFileSystemGCWii::GetFileName(u64 _Address)
return nullptr;
}
u64 CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize)
u64 CFileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize)
{
if (!m_Initialized)
InitFileSystem();
@ -75,14 +75,14 @@ u64 CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _Max
if (pFileInfo->m_FileSize > _MaxBufferSize)
return 0;
DEBUG_LOG(DISCIO, "Filename: %s. Offset: %" PRIx64 ". Size: %" PRIx64, _rFullPath,
DEBUG_LOG(DISCIO, "Filename: %s. Offset: %" PRIx64 ". Size: %" PRIx64, _rFullPath.c_str(),
pFileInfo->m_Offset, pFileInfo->m_FileSize);
m_rVolume->Read(pFileInfo->m_Offset, pFileInfo->m_FileSize, _pBuffer);
return pFileInfo->m_FileSize;
}
bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilename)
bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename)
{
if (!m_Initialized)
InitFileSystem();
@ -122,7 +122,7 @@ bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFi
return result;
}
bool CFileSystemGCWii::ExportApploader(const char* _rExportFolder) const
bool CFileSystemGCWii::ExportApploader(const std::string& _rExportFolder) const
{
u32 AppSize = Read32(0x2440 + 0x14);// apploader size
AppSize += Read32(0x2440 + 0x18); // + trailer size
@ -177,7 +177,7 @@ bool CFileSystemGCWii::GetBootDOL(u8* &buffer, u32 DolSize) const
return m_rVolume->Read(DolOffset, DolSize, buffer);
}
bool CFileSystemGCWii::ExportDOL(const char* _rExportFolder) const
bool CFileSystemGCWii::ExportDOL(const std::string& _rExportFolder) const
{
u32 DolOffset = Read32(0x420) << m_OffsetShift;
u32 DolSize = GetBootDOLSize();
@ -232,14 +232,14 @@ size_t CFileSystemGCWii::GetFileList(std::vector<const SFileInfo *> &_rFilenames
return m_FileInfoVector.size();
}
const SFileInfo* CFileSystemGCWii::FindFileInfo(const char* _rFullPath)
const SFileInfo* CFileSystemGCWii::FindFileInfo(const std::string& _rFullPath)
{
if (!m_Initialized)
InitFileSystem();
for (auto& fileInfo : m_FileInfoVector)
{
if (!strcasecmp(fileInfo.m_FullPath, _rFullPath))
if (!strcasecmp(fileInfo.m_FullPath, _rFullPath.c_str()))
return &fileInfo;
}

View File

@ -22,13 +22,13 @@ public:
CFileSystemGCWii(const IVolume* _rVolume);
virtual ~CFileSystemGCWii();
virtual bool IsValid() const override { return m_Valid; }
virtual u64 GetFileSize(const char* _rFullPath) override;
virtual u64 GetFileSize(const std::string& _rFullPath) override;
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) override;
virtual const char* GetFileName(u64 _Address) override;
virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) override;
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) override;
virtual bool ExportApploader(const char* _rExportFolder) const override;
virtual bool ExportDOL(const char* _rExportFolder) const override;
virtual u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) override;
virtual bool ExportFile(const std::string& _rFullPath, const std::string&_rExportFilename) override;
virtual bool ExportApploader(const std::string& _rExportFolder) const override;
virtual bool ExportDOL(const std::string& _rExportFolder) const override;
virtual bool GetBootDOL(u8* &buffer, u32 DolSize) const override;
virtual u32 GetBootDOLSize() const override;
@ -40,7 +40,7 @@ private:
std::vector <SFileInfo> m_FileInfoVector;
u32 Read32(u64 _Offset) const;
std::string GetStringFromOffset(u64 _Offset) const;
const SFileInfo* FindFileInfo(const char* _rFullPath);
const SFileInfo* FindFileInfo(const std::string& _rFullPath);
bool DetectFileSystem();
void InitFileSystem();
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset);

View File

@ -6,6 +6,7 @@
#include <cstddef>
#include <cstring>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
@ -43,11 +44,11 @@ public:
virtual ~IFileSystem();
virtual bool IsValid() const = 0;
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) = 0;
virtual u64 GetFileSize(const char* _rFullPath) = 0;
virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) = 0;
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) = 0;
virtual bool ExportApploader(const char* _rExportFolder) const = 0;
virtual bool ExportDOL(const char* _rExportFolder) const = 0;
virtual u64 GetFileSize(const std::string& _rFullPath) = 0;
virtual u64 ReadFile(const std::string& _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) = 0;
virtual bool ExportFile(const std::string& _rFullPath, const std::string& _rExportFilename) = 0;
virtual bool ExportApploader(const std::string& _rExportFolder) const = 0;
virtual bool ExportDOL(const std::string& _rExportFolder) const = 0;
virtual const char* GetFileName(u64 _Address) = 0;
virtual bool GetBootDOL(u8* &buffer, u32 DolSize) const = 0;
virtual u32 GetBootDOLSize() const = 0;

View File

@ -74,7 +74,7 @@ EDiscType GetDiscType(IBlobReader& _rReader);
IVolume* CreateVolumeFromFilename(const std::string& _rFilename, u32 _PartitionGroup, u32 _VolumeNum)
{
IBlobReader* pReader = CreateBlobReader(_rFilename.c_str());
IBlobReader* pReader = CreateBlobReader(_rFilename);
if (pReader == nullptr)
return nullptr;

View File

@ -133,7 +133,7 @@ bool CVolumeDirectory::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
_dbg_assert_(DVDINTERFACE, fileIter->first <= _Offset);
u64 fileOffset = _Offset - fileIter->first;
PlainFileReader* reader = PlainFileReader::Create(fileIter->second.c_str());
PlainFileReader* reader = PlainFileReader::Create(fileIter->second);
if (reader == nullptr)
return false;
@ -326,12 +326,12 @@ bool CVolumeDirectory::SetApploader(const std::string& _rApploader)
}
}
void CVolumeDirectory::SetDOL(const std::string& _rDOL)
void CVolumeDirectory::SetDOL(const std::string& rDOL)
{
if (!_rDOL.empty())
if (!rDOL.empty())
{
std::string data;
File::ReadFileToString(_rDOL.c_str(), data);
File::ReadFileToString(rDOL, data);
m_DOLSize = data.size();
m_DOL = new u8[m_DOLSize];
copy(data.begin(), data.end(), m_DOL);

View File

@ -23,10 +23,10 @@ static inline u64 align(u64 value, u64 bounds)
return (value + (bounds - 1)) & (~(bounds - 1));
}
WbfsFileReader::WbfsFileReader(const char* filename)
WbfsFileReader::WbfsFileReader(const std::string& filename)
: m_total_files(0), m_size(0), m_wlba_table(nullptr), m_good(true)
{
if (!filename || (strlen(filename) < 4) || !OpenFiles(filename) || !ReadHeader())
if (filename.length() < 4 || !OpenFiles(filename) || !ReadHeader())
{
m_good = false;
return;
@ -48,7 +48,7 @@ WbfsFileReader::~WbfsFileReader()
delete[] m_wlba_table;
}
bool WbfsFileReader::OpenFiles(const char* filename)
bool WbfsFileReader::OpenFiles(const std::string& filename)
{
m_total_files = 0;
@ -171,7 +171,7 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
return m_files[0]->file;
}
WbfsFileReader* WbfsFileReader::Create(const char* filename)
WbfsFileReader* WbfsFileReader::Create(const std::string& filename)
{
WbfsFileReader* reader = new WbfsFileReader(filename);
@ -186,7 +186,7 @@ WbfsFileReader* WbfsFileReader::Create(const char* filename)
}
}
bool IsWbfsBlob(const char* filename)
bool IsWbfsBlob(const std::string& filename)
{
File::IOFile f(filename, "rb");

View File

@ -4,6 +4,7 @@
#pragma once
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
@ -15,10 +16,10 @@ namespace DiscIO
class WbfsFileReader : public IBlobReader
{
WbfsFileReader(const char* filename);
WbfsFileReader(const std::string& filename);
~WbfsFileReader();
bool OpenFiles(const char* filename);
bool OpenFiles(const std::string& filename);
bool ReadHeader();
File::IOFile& SeekToCluster(u64 offset, u64* available);
@ -54,14 +55,14 @@ class WbfsFileReader : public IBlobReader
bool m_good;
public:
static WbfsFileReader* Create(const char* filename);
static WbfsFileReader* Create(const std::string& filename);
u64 GetDataSize() const override { return m_size; }
u64 GetRawSize() const override { return m_size; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr) override;
};
bool IsWbfsBlob(const char* filename);
bool IsWbfsBlob(const std::string& filename);
} // namespace

View File

@ -34,7 +34,7 @@ private:
WiiWAD::WiiWAD(const std::string& _rName)
{
DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName.c_str());
DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName);
if (pReader == nullptr || File::IsDirectory(_rName))
{
m_Valid = false;
@ -120,7 +120,7 @@ bool WiiWAD::ParseWAD(DiscIO::IBlobReader& _rReader)
bool WiiWAD::IsWiiWAD(const std::string& _rName)
{
DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName.c_str());
DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rName);
if (pReader == nullptr)
return false;

View File

@ -112,8 +112,8 @@ void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED (event))
if (pieces.size() == 2 && pieces[0].size() == 8 && pieces[1].size() == 8)
{
// Decrypted code line.
u32 addr = strtoul(pieces[0].c_str(), nullptr, 16);
u32 value = strtoul(pieces[1].c_str(), nullptr, 16);
u32 addr = std::stoul(pieces[0], nullptr, 16);
u32 value = std::stoul(pieces[1], nullptr, 16);
decryptedLines.push_back(ActionReplay::AREntry(addr, value));
continue;

View File

@ -1062,7 +1062,7 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA)
{
if (File::Exists(filename))
{
GCMemcard memorycard(filename.c_str());
GCMemcard memorycard(filename);
if (!memorycard.IsValid())
{
PanicAlertT("Cannot use that file as a memory card.\n%s\n" \

View File

@ -42,7 +42,7 @@ void BreakPointDlg::OnOK(wxCommandEvent& event)
{
wxString AddressString = m_pEditAddress->GetLineText(0);
u32 Address = 0;
if (AsciiToHex(WxStrToStr(AddressString).c_str(), Address))
if (AsciiToHex(WxStrToStr(AddressString), Address))
{
PowerPC::breakpoints.Add(Address);
Parent->NotifyUpdate();

View File

@ -195,7 +195,7 @@ void CCodeWindow::OnProfilerMenu(wxCommandEvent& event)
{
std::string filename = File::GetUserPath(D_DUMP_IDX) + "Debug/profiler.txt";
File::CreateFullPath(filename);
Profiler::WriteProfileResults(filename.c_str());
Profiler::WriteProfileResults(filename);
wxFileType* filetype = nullptr;
if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("txt"))))
@ -235,7 +235,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
{
PPCAnalyst::FindFunctions(0x80000000, 0x81800000, &g_symbolDB);
SignatureDB db;
if (db.Load((File::GetSysDirectory() + TOTALDB).c_str()))
if (db.Load(File::GetSysDirectory() + TOTALDB))
{
db.Apply(&g_symbolDB);
Parent->StatusBarMessage("Generated symbol names from '%s'", TOTALDB);
@ -255,23 +255,23 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
g_symbolDB.Clear();
PPCAnalyst::FindFunctions(0x81300000, 0x81800000, &g_symbolDB);
SignatureDB db;
if (db.Load((File::GetSysDirectory() + TOTALDB).c_str()))
if (db.Load(File::GetSysDirectory() + TOTALDB))
db.Apply(&g_symbolDB);
Parent->StatusBarMessage("'%s' not found, scanning for common functions instead", writable_map_file.c_str());
}
else
{
g_symbolDB.LoadMap(existing_map_file.c_str());
g_symbolDB.LoadMap(existing_map_file);
Parent->StatusBarMessage("Loaded symbols from '%s'", existing_map_file.c_str());
}
HLE::PatchFunctions();
NotifyMapLoaded();
break;
case IDM_SAVEMAPFILE:
g_symbolDB.SaveMap(writable_map_file.c_str());
g_symbolDB.SaveMap(writable_map_file);
break;
case IDM_SAVEMAPFILEWITHCODES:
g_symbolDB.SaveMap(writable_map_file.c_str(), true);
g_symbolDB.SaveMap(writable_map_file, true);
break;
case IDM_RENAME_SYMBOLS:
@ -328,8 +328,8 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
if (!path.IsEmpty())
{
SignatureDB db;
db.Initialize(&g_symbolDB, prefix.c_str());
db.Save(WxStrToStr(path).c_str());
db.Initialize(&g_symbolDB, prefix);
db.Save(WxStrToStr(path));
}
}
}
@ -343,7 +343,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
if (!path.IsEmpty())
{
SignatureDB db;
db.Load(WxStrToStr(path).c_str());
db.Load(WxStrToStr(path));
db.Apply(&g_symbolDB);
}
}

View File

@ -278,50 +278,50 @@ void GFXDebuggerPanel::OnDumpButton(wxCommandEvent& event)
switch (m_pDumpList->GetSelection())
{
case 0: // Pixel Shader
DumpPixelShader(dump_path.c_str());
DumpPixelShader(dump_path);
break;
case 1: // Vertex Shader
DumpVertexShader(dump_path.c_str());
DumpVertexShader(dump_path);
break;
case 2: // Pixel Shader Constants
DumpPixelShaderConstants(dump_path.c_str());
DumpPixelShaderConstants(dump_path);
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
break;
case 3: // Vertex Shader Constants
DumpVertexShaderConstants(dump_path.c_str());
DumpVertexShaderConstants(dump_path);
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
break;
case 4: // Textures
DumpTextures(dump_path.c_str());
DumpTextures(dump_path);
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
break;
case 5: // Frame Buffer
DumpFrameBuffer(dump_path.c_str());
DumpFrameBuffer(dump_path);
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
break;
case 6: // Geometry
DumpGeometry(dump_path.c_str());
DumpGeometry(dump_path);
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
break;
case 7: // Vertex Description
DumpVertexDecl(dump_path.c_str());
DumpVertexDecl(dump_path);
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
break;
case 8: // Vertex Matrices
DumpMatrices(dump_path.c_str());
DumpMatrices(dump_path);
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
break;
case 9: // Statistics
DumpStats(dump_path.c_str());
DumpStats(dump_path);
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
break;
}

View File

@ -81,9 +81,9 @@ void MemoryCheckDlg::OnOK(wxCommandEvent& event)
u32 StartAddress, EndAddress;
bool EndAddressOK = EndAddressString.Len() &&
AsciiToHex(WxStrToStr(EndAddressString).c_str(), EndAddress);
AsciiToHex(WxStrToStr(EndAddressString), EndAddress);
if (AsciiToHex(WxStrToStr(StartAddressString).c_str(), StartAddress) &&
if (AsciiToHex(WxStrToStr(StartAddressString), StartAddress) &&
(OnRead || OnWrite) && (Log || Break))
{
TMemCheck MemCheck;

View File

@ -413,7 +413,7 @@ void FifoPlayerDlg::OnSaveFile(wxCommandEvent& WXUNUSED(event))
{
// Attempt to save the file to the path the user chose
wxBeginBusyCursor();
bool result = file->Save(WxStrToStr(path).c_str());
bool result = file->Save(WxStrToStr(path));
wxEndBusyCursor();
// Wasn't able to save the file, shit's whack, yo.

View File

@ -579,7 +579,7 @@ void CFrame::OnToolBar(wxCommandEvent& event)
}
SaveIniPerspectives();
GetStatusBar()->SetStatusText(StrToWxStr(std::string
("Saved " + Perspectives[ActivePerspective].Name).c_str()), 0);
("Saved " + Perspectives[ActivePerspective].Name)), 0);
break;
case IDM_PERSPECTIVES_ADD_PANE:
AddPane();
@ -869,12 +869,14 @@ void CFrame::LoadIniPerspectives()
for (auto& Width : _SWidth)
{
int _Tmp;
if (TryParse(Width.c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp);
if (TryParse(Width, &_Tmp))
Tmp.Width.push_back(_Tmp);
}
for (auto& Height : _SHeight)
{
int _Tmp;
if (TryParse(Height.c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp);
if (TryParse(Height, &_Tmp))
Tmp.Height.push_back(_Tmp);
}
Perspectives.push_back(Tmp);
}

View File

@ -674,7 +674,7 @@ void CFrame::DoOpen(bool Boot)
}
else
{
DVDInterface::ChangeDisc(WxStrToStr(path).c_str());
DVDInterface::ChangeDisc(WxStrToStr(path));
}
}
@ -771,7 +771,7 @@ void CFrame::OnPlayRecording(wxCommandEvent& WXUNUSED (event))
GetMenuBar()->FindItem(IDM_RECORDREADONLY)->Check(true);
}
if (Movie::PlayInput(WxStrToStr(path).c_str()))
if (Movie::PlayInput(WxStrToStr(path)))
BootGame(std::string(""));
}
@ -1183,7 +1183,7 @@ void CFrame::DoRecordingSave()
if (path.IsEmpty())
return;
Movie::SaveRecording(WxStrToStr(path).c_str());
Movie::SaveRecording(WxStrToStr(path));
if (!paused)
DoPause();
@ -1822,7 +1822,7 @@ void CFrame::GameListChanged(wxCommandEvent& event)
break;
case IDM_PURGECACHE:
CFileSearch::XStringVector Directories;
Directories.push_back(File::GetUserPath(D_CACHE_IDX).c_str());
Directories.push_back(File::GetUserPath(D_CACHE_IDX));
CFileSearch::XStringVector Extensions;
Extensions.push_back("*.cache");

Some files were not shown because too many files have changed in this diff Show More