Convert GetUserPath to return a std::string instead of a const char *. This simplifies its usage in most cases.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7265 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2011-02-28 20:40:15 +00:00
parent 1b8f476024
commit ba54fac9eb
82 changed files with 408 additions and 449 deletions

View File

@ -94,7 +94,7 @@ std::string CBoot::GenerateMapFilename()
u64 TitleID = Loader.GetTitleID();
char tmpBuffer[32];
sprintf(tmpBuffer, "%08x_%08x", (u32)(TitleID >> 32) & 0xFFFFFFFF , (u32)TitleID & 0xFFFFFFFF );
return std::string(File::GetUserPath(D_MAPS_IDX)) + std::string(tmpBuffer) + ".map";
return File::GetUserPath(D_MAPS_IDX) + std::string(tmpBuffer) + ".map";
}
break;
}
@ -103,7 +103,7 @@ std::string CBoot::GenerateMapFilename()
case SCoreStartupParameter::BOOT_DOL:
return _StartupPara.m_strFilename.substr(0, _StartupPara.m_strFilename.size()-4) + ".map";
default:
return std::string(File::GetUserPath(D_MAPS_IDX)) + _StartupPara.GetUniqueID() + ".map";
return File::GetUserPath(D_MAPS_IDX) + _StartupPara.GetUniqueID() + ".map";
}
return std::string("unknown map");

View File

@ -46,9 +46,10 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename)
char Path[260+1];
u64 TitleID = ContentLoader.GetTitleID();
char* pTitleID = (char*)&TitleID;
sprintf(Path, "%stitle/%02x%02x%02x%02x/%02x%02x%02x%02x/data/nocopy/", File::GetUserPath(D_WIIUSER_IDX),
(u8)pTitleID[7], (u8)pTitleID[6], (u8)pTitleID[5], (u8)pTitleID[4],
(u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]);
sprintf(Path, "%stitle/%02x%02x%02x%02x/%02x%02x%02x%02x/data/nocopy/",
File::GetUserPath(D_WIIUSER_IDX).c_str(),
(u8)pTitleID[7], (u8)pTitleID[6], (u8)pTitleID[5], (u8)pTitleID[4],
(u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]);
File::CreateFullPath(Path);
// setup wii mem
@ -100,7 +101,8 @@ bool CBoot::Install_WiiWAD(const char* _pFilename)
//copy WAD's tmd header and contents to content directory
char ContentPath[260+1];
sprintf(ContentPath, "%stitle/%08x/%08x/content/", File::GetUserPath(D_WIIUSER_IDX), TitleID_HI, TitleID_LO);
sprintf(ContentPath, "%stitle/%08x/%08x/content/",
File::GetUserPath(D_WIIUSER_IDX).c_str(), TitleID_HI, TitleID_LO);
File::CreateFullPath(ContentPath);
std::string TMDFileName(ContentPath);
@ -155,11 +157,12 @@ bool CBoot::Install_WiiWAD(const char* _pFilename)
//Extract and copy WAD's ticket to ticket directory
char TicketPath[260+1];
sprintf(TicketPath, "%sticket/%08x/", File::GetUserPath(D_WIIUSER_IDX), TitleID_HI);
sprintf(TicketPath, "%sticket/%08x/", File::GetUserPath(D_WIIUSER_IDX).c_str(), TitleID_HI);
File::CreateFullPath(TicketPath);
char TicketFileName[260+1];
sprintf(TicketFileName, "%sticket/%08x/%08x.tik", File::GetUserPath(D_WIIUSER_IDX), TitleID_HI, TitleID_LO);
sprintf(TicketFileName, "%sticket/%08x/%08x.tik",
File::GetUserPath(D_WIIUSER_IDX).c_str(), TitleID_HI, TitleID_LO);
FILE* pTicketFile = fopen(TicketFileName, "wb");
if (pTicketFile == NULL) {

View File

@ -84,7 +84,7 @@ bool BootCore(const std::string& _rFilename)
// Load game specific settings
IniFile game_ini;
std::string unique_id = StartUp.GetUniqueID();
StartUp.m_strGameIni = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + unique_id + ".ini";
StartUp.m_strGameIni = File::GetUserPath(D_GAMECONFIG_IDX) + unique_id + ".ini";
if (unique_id.size() == 6 && game_ini.Load(StartUp.m_strGameIni.c_str()))
{
config_cache.valid = true;

View File

@ -124,7 +124,7 @@ SConfig::~SConfig()
void SConfig::SaveSettings()
{
NOTICE_LOG(BOOT, "Saving settings to %s", File::GetUserPath(F_DOLPHINCONFIG_IDX));
NOTICE_LOG(BOOT, "Saving settings to %s", File::GetUserPath(F_DOLPHINCONFIG_IDX).c_str());
IniFile ini;
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); // load first to not kill unknown stuff
@ -239,7 +239,7 @@ void SConfig::SaveSettings()
void SConfig::LoadSettings()
{
INFO_LOG(BOOT, "Loading Settings from %s", File::GetUserPath(F_DOLPHINCONFIG_IDX));
INFO_LOG(BOOT, "Loading Settings from %s", File::GetUserPath(F_DOLPHINCONFIG_IDX).c_str());
IniFile ini;
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
@ -372,14 +372,14 @@ void SConfig::LoadSettingsWii()
{
IniFile ini;
//Wiimote configs
ini.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "Dolphin.ini").c_str());
ini.Load((File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini"));
for (int i = 0; i < 4; i++)
{
char SectionName[32];
sprintf(SectionName, "Wiimote%i", i + 1);
ini.Get(SectionName, "AutoReconnectRealWiimote", &m_WiiAutoReconnect[i], false);
}
ini.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "wiimote.ini").c_str());
ini.Load((File::GetUserPath(D_CONFIG_IDX) + "wiimote.ini"));
ini.Get("Real", "Unpair", &m_WiiAutoUnpair, false);
}

View File

@ -497,11 +497,11 @@ static inline std::string GenerateScreenshotName()
int index = 1;
std::string tempname, name;
std::string gameId = SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID();
tempname = std::string(File::GetUserPath(D_SCREENSHOTS_IDX)) + gameId + DIR_SEP_CHR;
tempname = File::GetUserPath(D_SCREENSHOTS_IDX) + gameId + DIR_SEP_CHR;
if (!File::CreateFullPath(tempname.c_str())) {
//fallback to old-style screenshots, without folder.
tempname = std::string(File::GetUserPath(D_SCREENSHOTS_IDX));
tempname = File::GetUserPath(D_SCREENSHOTS_IDX);
}
//append gameId, tempname only contains the folder here.
tempname += gameId;

View File

@ -327,7 +327,7 @@ void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::stri
{
// Use default memcard path if there is no user defined name
std::string defaultFilename = isSlotA ? GC_MEMCARDA : GC_MEMCARDB;
memcardPath = std::string(File::GetUserPath(D_GCUSER_IDX)) + defaultFilename + ext;
memcardPath = File::GetUserPath(D_GCUSER_IDX) + defaultFilename + ext;
}
else
{

View File

@ -49,9 +49,8 @@ DSPDisassembler::DSPDisassembler(const AssemblerSettings &settings)
DSPDisassembler::~DSPDisassembler()
{
// Some old code for logging unknown ops.
char filename[MAX_PATH];
sprintf(filename, "%sUnkOps.txt", File::GetUserPath(D_DUMPDSP_IDX));
FILE *uo = fopen(filename, "w");
std::string filename = File::GetUserPath(D_DUMPDSP_IDX) + "UnkOps.txt";
FILE *uo = fopen(filename.c_str(), "w");
if (!uo)
return;

View File

@ -100,7 +100,7 @@ void CUCode_Rom::BootUCode()
#if defined(_DEBUG) || defined(DEBUGFAST)
char binFile[MAX_PATH];
sprintf(binFile, "%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX), ector_crc);
sprintf(binFile, "%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), ector_crc);
FILE* pFile = fopen(binFile, "wb");
if (pFile)

View File

@ -146,7 +146,7 @@ void IUCode::PrepareBootUCode(u32 mail)
#if defined(_DEBUG) || defined(DEBUGFAST)
char binFile[MAX_PATH];
sprintf(binFile, "%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX), ector_crc);
sprintf(binFile, "%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), ector_crc);
FILE* pFile = fopen(binFile, "wb");
if (pFile)

View File

@ -106,20 +106,14 @@ void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
m_bDSPThread = bDSPThread;
m_InitMixer = false;
bool bCanWork = true;
char irom_file[MAX_PATH];
char coef_file[MAX_PATH];
std::string irom_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_IROM;
std::string coef_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_COEF;
snprintf(irom_file, MAX_PATH, "%s%s",
File::GetSysDirectory().c_str(), GC_SYS_DIR DIR_SEP DSP_IROM);
if (!File::Exists(irom_file))
snprintf(irom_file, MAX_PATH, "%s%s",
File::GetUserPath(D_GCUSER_IDX), DIR_SEP DSP_IROM);
snprintf(coef_file, MAX_PATH, "%s%s",
File::GetSysDirectory().c_str(), GC_SYS_DIR DIR_SEP DSP_COEF);
if (!File::Exists(coef_file))
snprintf(coef_file, MAX_PATH, "%s%s",
File::GetUserPath(D_GCUSER_IDX), DIR_SEP DSP_COEF);
bCanWork = DSPCore_Init(irom_file, coef_file, AudioCommon::UseJIT());
if (!File::Exists(irom_file.c_str()))
irom_file = File::GetUserPath(D_GCUSER_IDX) + DIR_SEP DSP_IROM;
if (!File::Exists(coef_file.c_str()))
coef_file = File::GetUserPath(D_GCUSER_IDX) + DIR_SEP DSP_COEF;
bCanWork = DSPCore_Init(irom_file.c_str(), coef_file.c_str(), AudioCommon::UseJIT());
g_dsp.cpu_ram = Memory::GetPointer(0);
DSPCore_Reset();

View File

@ -32,8 +32,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), crc);
sprintf(txtFile, "%sDSP_UC_%08X.txt", File::GetUserPath(D_DUMPDSP_IDX), crc);
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);
FILE* pFile = fopen(binFile, "wb");
if (pFile)
@ -70,9 +70,8 @@ bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc)
// TODO make this useful :p
bool DumpCWCode(u32 _Address, u32 _Length)
{
char filename[256];
sprintf(filename, "%sDSP_UCode.bin", File::GetUserPath(D_DUMPDSP_IDX));
FILE* pFile = fopen(filename, "wb");
std::string filename = File::GetUserPath(D_DUMPDSP_IDX) + "DSP_UCode.bin";
FILE* pFile = fopen(filename.c_str(), "wb");
if (pFile != NULL)
{

View File

@ -294,7 +294,7 @@ void Wiimote::WriteData(const wm_write_data* const wd)
{
// writing the whole mii block each write :/
std::ofstream file;
file.open( (std::string(File::GetUserPath(D_WIIUSER_IDX)) + "mii.bin").c_str(), std::ios::binary | std::ios::out);
file.open((File::GetUserPath(D_WIIUSER_IDX) + "mii.bin").c_str(), std::ios::binary | std::ios::out);
file.write((char*)m_eeprom + 0x0FCA, 0x02f0);
file.close();
}
@ -427,7 +427,7 @@ void Wiimote::ReadData(const wm_read_data* const rd)
{
// reading the whole mii block :/
std::ifstream file;
file.open((std::string(File::GetUserPath(D_WIIUSER_IDX)) + "mii.bin").c_str(), std::ios::binary | std::ios::in);
file.open((File::GetUserPath(D_WIIUSER_IDX) + "mii.bin").c_str(), std::ios::binary | std::ios::in);
file.read((char*)m_eeprom + 0x0FCA, 0x02f0);
file.close();
}

View File

@ -346,7 +346,7 @@ static int ConnectWiimotes(Wiimote** wm)
void LoadSettings()
{
std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + WIIMOTE_INI_NAME ".ini" );
std::string ini_filename = File::GetUserPath(D_CONFIG_IDX) + WIIMOTE_INI_NAME ".ini";
IniFile inifile;
inifile.Load(ini_filename);

View File

@ -209,7 +209,7 @@ void CopySettingsFile(std::string& DeviceName)
else
Source += "setting-eur.txt";
std::string Target = std::string(File::GetUserPath(D_WIIUSER_IDX)) + DeviceName;
std::string Target = File::GetUserPath(D_WIIUSER_IDX) + DeviceName;
// Check if the target dir exists, otherwise create it
std::string TargetDir = Target.substr(0, Target.find_last_of(DIR_SEP));

View File

@ -31,7 +31,7 @@ static Common::replace_v replacements;
// This is used by several of the FileIO and /dev/fs/ functions
std::string HLE_IPC_BuildFilename(const char* _pFilename, int _size)
{
std::string path_full = std::string(File::GetUserPath(D_WIIROOT_IDX));
std::string path_full = File::GetUserPath(D_WIIROOT_IDX);
std::string path_wii(_pFilename);
if ((path_wii.length() > 0) && (path_wii[1] == '0'))

View File

@ -46,10 +46,9 @@ bool CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
{
// clear tmp folder
{
char Path[260];
snprintf(Path, sizeof(Path), "%stmp", File::GetUserPath(D_WIIUSER_IDX));
File::DeleteDirRecursively(Path);
File::CreateDir(Path);
std::string Path = File::GetUserPath(D_WIIUSER_IDX) + "tmp";
File::DeleteDirRecursively(Path.c_str());
File::CreateDir(Path.c_str());
}
// create home directory
@ -66,7 +65,8 @@ bool CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
if (GameID == 0) GameID = 0xF00DBEEF;
if (TitleID == 0) TitleID = 0x00010000;
snprintf(Path, sizeof(Path), "%stitle/%08x/%08x/data/nocopy/", File::GetUserPath(D_WIIUSER_IDX), TitleID, GameID);
snprintf(Path, sizeof(Path), "%stitle/%08x/%08x/data/nocopy/",
File::GetUserPath(D_WIIUSER_IDX).c_str(), TitleID, GameID);
File::CreateFullPath(Path);
}

View File

@ -60,16 +60,15 @@ bool CWII_IPC_HLE_Device_sdio_slot0::Open(u32 _CommandAddress, u32 _Mode)
{
INFO_LOG(WII_IPC_SD, "Open");
char filename[300];
sprintf(filename, "%ssd.raw", File::GetUserPath(D_WIIUSER_IDX));
m_Card = fopen(filename, "r+b");
std::string filename = File::GetUserPath(D_WIIUSER_IDX) + "sd.raw";
m_Card = fopen(filename.c_str(), "r+b");
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))
if (SDCardCreate(128, filename.c_str()))
{
WARN_LOG(WII_IPC_SD, "Successfully created %s", filename);
m_Card = fopen(filename, "r+b");
WARN_LOG(WII_IPC_SD, "Successfully created %s", filename.c_str());
m_Card = fopen(filename.c_str(), "r+b");
}
if(!m_Card)
{

View File

@ -154,7 +154,7 @@ int GetSpeedhackCycles(const u32 addr)
void LoadPatches(const char *gameID)
{
IniFile ini;
std::string filename = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + gameID + ".ini";
std::string filename = File::GetUserPath(D_GAMECONFIG_IDX) + gameID + ".ini";
if (ini.Load(filename.c_str())) {
LoadPatchSection("OnFrame", onFrame, ini);
ActionReplay::LoadCodes(ini, false);

View File

@ -234,7 +234,7 @@ void PrintInstructionRunCounts()
void LogCompiledInstructions()
{
static int time = 0;
FILE *f = fopen(StringFromFormat("%sinst_log%i.txt", File::GetUserPath(D_LOGS_IDX), time).c_str(), "w");
FILE *f = fopen(StringFromFormat("%sinst_log%i.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time).c_str(), "w");
for (int i = 0; i < m_numInstructions; i++)
{
if (m_allInstructions[i]->compileCount > 0) {
@ -242,7 +242,7 @@ void LogCompiledInstructions()
}
}
fclose(f);
f = fopen(StringFromFormat("%sinst_not%i.txt", File::GetUserPath(D_LOGS_IDX), time).c_str(), "w");
f = fopen(StringFromFormat("%sinst_not%i.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time).c_str(), "w");
for (int i = 0; i < m_numInstructions; i++)
{
if (m_allInstructions[i]->compileCount == 0) {
@ -251,7 +251,7 @@ void LogCompiledInstructions()
}
fclose(f);
#ifdef OPLOG
f = fopen(StringFromFormat("%s" OP_TO_LOG "_at.txt", File::GetUserPath(D_LOGS_IDX), time).c_str(), "w");
f = fopen(StringFromFormat("%s" OP_TO_LOG "_at.txt", File::GetUserPath(D_LOGS_IDX).c_str(), time).c_str(), "w");
for (size_t i = 0; i < rsplocations.size(); i++) {
fprintf(f, OP_TO_LOG ": %08x\n", rsplocations[i]);
}

View File

@ -38,12 +38,12 @@ struct BlockStat
int blockNum;
u64 cost;
bool operator <(const BlockStat &other) const {
return cost > other.cost;
}
bool operator <(const BlockStat &other) const
{ return cost > other.cost; }
};
void WriteProfileResults(const char *filename) {
void WriteProfileResults(const char *filename)
{
std::vector<BlockStat> stats;
stats.reserve(jit->GetBlockCache()->GetNumBlocks());
u64 cost_sum = 0;
@ -55,13 +55,14 @@ void WriteProfileResults(const char *filename) {
for (int i = 0; i < jit->GetBlockCache()->GetNumBlocks(); i++)
{
const JitBlock *block = jit->GetBlockCache()->GetBlock(i);
u64 cost = block->originalSize * (block->runCount / 4); // rough heuristic. mem instructions should cost more.
// Rough heuristic. Mem instructions should cost more.
u64 cost = block->originalSize * (block->runCount / 4);
#ifdef _WIN32
u64 timecost = block->ticCounter; // Indeed ;)
u64 timecost = block->ticCounter;
#endif
if (block->runCount >= 1) { // Todo: tweak.
// Todo: tweak.
if (block->runCount >= 1)
stats.push_back(BlockStat(i, cost));
}
cost_sum += cost;
#ifdef _WIN32
timecost_sum += timecost;
@ -70,7 +71,8 @@ void WriteProfileResults(const char *filename) {
sort(stats.begin(), stats.end());
FILE *f = fopen(filename, "w");
if (!f) {
if (!f)
{
PanicAlert("failed to open %s", filename);
return;
}
@ -85,10 +87,12 @@ void WriteProfileResults(const char *filename) {
#ifdef _WIN32
double timePercent = 100.0 * (double)block->ticCounter / (double)timecost_sum;
fprintf(f, "%08x\t%s\t%llu\t%llu\t%.2lf\t%llf\t%lf\t%i\n",
block->originalAddress, name.c_str(), stats[i].cost, block->ticCounter, percent, timePercent, (double)block->ticCounter*1000.0/(double)countsPerSec, block->codeSize);
block->originalAddress, name.c_str(), stats[i].cost,
block->ticCounter, percent, timePercent,
(double)block->ticCounter*1000.0/(double)countsPerSec, block->codeSize);
#else
fprintf(f, "%08x\t%s\t%llu\t???\t%.2lf\t???\t???\t%i\n",
block->originalAddress, name.c_str(), stats[i].cost, /*block->ticCounter.QuadPart,*/ percent, /*timePercent, (double)block->ticCounter.QuadPart*1000.0/(double)countsPerSec.QuadPart,*/ block->codeSize);
block->originalAddress, name.c_str(), stats[i].cost, percent, block->codeSize);
#endif
}
}

View File

@ -181,10 +181,10 @@ void CompressAndDumpState(saveStruct* saveArg)
// Moving to last overwritten save-state
if (File::Exists(cur_filename.c_str()))
{
if (File::Exists((std::string(File::GetUserPath(D_STATESAVES_IDX)) + "lastState.sav").c_str()))
File::Delete((std::string(File::GetUserPath(D_STATESAVES_IDX)) + "lastState.sav").c_str());
if (File::Exists((File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav").c_str()))
File::Delete((File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav").c_str());
if (!File::Rename(cur_filename.c_str(), (std::string(File::GetUserPath(D_STATESAVES_IDX)) + "lastState.sav").c_str()))
if (!File::Rename(cur_filename.c_str(), (File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav").c_str()))
Core::DisplayMessage("Failed to move previous state to state undo backup", 1000);
}
@ -515,7 +515,7 @@ void State_Shutdown()
static std::string MakeStateFilename(int state_number)
{
return StringFromFormat("%s%s.s%02i", File::GetUserPath(D_STATESAVES_IDX), SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str(), state_number);
return StringFromFormat("%s%s.s%02i", File::GetUserPath(D_STATESAVES_IDX).c_str(), SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str(), state_number);
}
void State_SaveAs(const std::string &filename)
@ -614,7 +614,7 @@ void State_UndoLoadState()
// Load the state that the last save state overwritten on
void State_UndoSaveState()
{
State_LoadAs((std::string(File::GetUserPath(D_STATESAVES_IDX)) + "lastState.sav").c_str());
State_LoadAs((File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav").c_str());
}
size_t State_GetSize()