More conversion from char * to std::string.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7266 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2011-03-01 03:06:14 +00:00
parent ba54fac9eb
commit a5b471f490
37 changed files with 338 additions and 444 deletions

View File

@ -288,7 +288,7 @@ bool CBoot::BootUp()
// ELF
case SCoreStartupParameter::BOOT_ELF:
{
if(!File::Exists(_StartupPara.m_strFilename.c_str()))
if(!File::Exists(_StartupPara.m_strFilename))
{
PanicAlertT("The file you specified (%s) does not exist",
_StartupPara.m_strFilename.c_str());

View File

@ -499,7 +499,8 @@ static inline std::string GenerateScreenshotName()
std::string gameId = SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID();
tempname = File::GetUserPath(D_SCREENSHOTS_IDX) + gameId + DIR_SEP_CHR;
if (!File::CreateFullPath(tempname.c_str())) {
if (!File::CreateFullPath(tempname))
{
//fallback to old-style screenshots, without folder.
tempname = File::GetUserPath(D_SCREENSHOTS_IDX);
}
@ -508,7 +509,7 @@ static inline std::string GenerateScreenshotName()
do
name = StringFromFormat("%s-%d.png", tempname.c_str(), index++);
while (File::Exists(name.c_str()));
while (File::Exists(name));
return name;
}

View File

@ -114,7 +114,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
bool bootDrive = cdio_is_cdrom(m_strFilename);
// Check if the file exist, we may have gotten it from a --elf command line
// that gave an incorrect file name
if (!bootDrive && !File::Exists(m_strFilename.c_str()))
if (!bootDrive && !File::Exists(m_strFilename))
{
PanicAlertT("The specified file \"%s\" does not exist", m_strFilename.c_str());
return false;
@ -304,7 +304,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
m_strBootROM = File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + Region + DIR_SEP GC_IPL;
if (!bHLE_BS2)
{
if (!File::Exists(m_strBootROM.c_str()))
if (!File::Exists(m_strBootROM))
{
WARN_LOG(BOOT, "bootrom file %s not found - using HLE.", m_strBootROM.c_str());
bHLE_BS2 = true;
@ -340,7 +340,7 @@ void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::stri
if (!hasregion)
{
// filename doesn't have region in the extension
if (File::Exists(filename.c_str()))
if (File::Exists(filename))
{
// If the old file exists we are polite and ask if we should copy it
std::string oldFilename = filename;
@ -352,7 +352,7 @@ void SCoreStartupParameter::CheckMemcardPath(std::string& memcardPath, std::stri
"Would you like to copy the old file to this new location?\n",
isSlotA ? 'A':'B', isSlotA ? 'A':'B', filename.c_str()))
{
if (!File::Copy(oldFilename.c_str(), filename.c_str()))
if (!File::Copy(oldFilename, filename))
PanicAlertT("Copy failed");
}
}

View File

@ -109,9 +109,9 @@ void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
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;
if (!File::Exists(irom_file.c_str()))
if (!File::Exists(irom_file))
irom_file = File::GetUserPath(D_GCUSER_IDX) + DIR_SEP DSP_IROM;
if (!File::Exists(coef_file.c_str()))
if (!File::Exists(coef_file))
coef_file = File::GetUserPath(D_GCUSER_IDX) + DIR_SEP DSP_COEF;
bCanWork = DSPCore_Init(irom_file.c_str(), coef_file.c_str(), AudioCommon::UseJIT());

View File

@ -111,8 +111,8 @@ void innerFlush(flushStruct* data)
{
std::string dir;
SplitPath(data->filename, &dir, 0, 0);
if(!File::IsDirectory(dir.c_str()))
File::CreateFullPath(dir.c_str());
if(!File::IsDirectory(dir))
File::CreateFullPath(dir);
pFile = fopen(data->filename.c_str(), "wb");
}

View File

@ -213,10 +213,10 @@ void CopySettingsFile(std::string& DeviceName)
// Check if the target dir exists, otherwise create it
std::string TargetDir = Target.substr(0, Target.find_last_of(DIR_SEP));
if (!File::IsDirectory(TargetDir.c_str()))
File::CreateFullPath(Target.c_str());
if (!File::IsDirectory(TargetDir))
File::CreateFullPath(Target);
if (File::Copy(Source.c_str(), Target.c_str()))
if (File::Copy(Source, Target))
{
INFO_LOG(WII_IPC_FILEIO, "FS: Copied %s to %s", Source.c_str(), Target.c_str());
}

View File

@ -108,7 +108,7 @@ bool CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
// The file must exist before we can open it
// It should be created by ISFS_CreateFile, not here
if(File::Exists(m_Filename.c_str()))
if(File::Exists(m_Filename))
{
INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s)", m_Name.c_str(), Modes[_Mode]);
switch(_Mode)

View File

@ -445,11 +445,11 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
std::string TicketFilename = Common::CreateTicketFileName(TitleID);
u32 ViewCount = 0;
if (File::Exists(TicketFilename.c_str()))
if (File::Exists(TicketFilename))
{
const u32 SIZE_OF_ONE_TICKET = 676;
u32 FileSize = (u32)(File::GetSize(TicketFilename.c_str()));
u32 FileSize = (u32)(File::GetSize(TicketFilename));
_dbg_assert_msg_(WII_IPC_ES, (FileSize % SIZE_OF_ONE_TICKET) == 0, "IOCTL_ES_GETVIEWCNT ticket file size seems to be wrong");
ViewCount = FileSize / SIZE_OF_ONE_TICKET;
@ -481,7 +481,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
u32 maxViews = Memory::Read_U32(Buffer.InBuffer[1].m_Address);
std::string TicketFilename = Common::CreateTicketFileName(TitleID);
if (File::Exists(TicketFilename.c_str()))
if (File::Exists(TicketFilename))
{
const u32 SIZE_OF_ONE_TICKET = 676;
FILE* pFile = fopen(TicketFilename.c_str(), "rb");
@ -807,9 +807,9 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz)
dataPath = Common::CreateTitleDataPath(tmdTitleID) + DIR_SEP;
tmdPath = contentPath + "/title.tmd";
File::CreateFullPath(contentPath.c_str());
File::CreateFullPath(dataPath.c_str());
if(!File::Exists(tmdPath.c_str()))
File::CreateFullPath(contentPath);
File::CreateFullPath(dataPath);
if(!File::Exists(tmdPath))
{
FILE* _pTMDFile = fopen(tmdPath.c_str(), "wb");
if (_pTMDFile)

View File

@ -47,7 +47,7 @@ bool CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
// clear tmp folder
{
std::string Path = File::GetUserPath(D_WIIUSER_IDX) + "tmp";
File::DeleteDirRecursively(Path.c_str());
File::DeleteDirRecursively(Path);
File::CreateDir(Path.c_str());
}
@ -125,7 +125,7 @@ bool CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
INFO_LOG(WII_IPC_FILEIO, "FS: IOCTL_READ_DIR %s", DirName.c_str());
if (!File::Exists(DirName.c_str()))
if (!File::Exists(DirName))
{
WARN_LOG(WII_IPC_FILEIO, "FS: Search not found: %s", DirName.c_str());
ReturnValue = FS_DIRFILE_NOT_FOUND;
@ -133,7 +133,7 @@ bool CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
}
// AyuanX: what if we return "found one successfully" if it is a file?
else if (!File::IsDirectory(DirName.c_str()))
else if (!File::IsDirectory(DirName))
{
// It's not a directory, so error.
// Games don't usually seem to care WHICH error they get, as long as it's <0
@ -214,10 +214,10 @@ bool CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress)
u32 iNodes = 0;
INFO_LOG(WII_IPC_FILEIO, "IOCTL_GETUSAGE %s", path.c_str());
if (File::IsDirectory(path.c_str()))
if (File::IsDirectory(path))
{
File::FSTEntry parentDir;
iNodes = File::ScanDirectoryTree(path.c_str(), parentDir);
iNodes = File::ScanDirectoryTree(path, parentDir);
u64 totalSize = ComputeTotalFileSize(parentDir); // "Real" size, to be converted to nand blocks
@ -315,8 +315,8 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
INFO_LOG(WII_IPC_FILEIO, "FS: CREATE_DIR %s, OwnerID %#x, GroupID %#x, Attributes %#x", DirName.c_str(), OwnerID, GroupID, Attribs);
DirName += DIR_SEP;
File::CreateFullPath(DirName.c_str());
_dbg_assert_msg_(WII_IPC_FILEIO, File::IsDirectory(DirName.c_str()), "FS: CREATE_DIR %s failed", DirName.c_str());
File::CreateFullPath(DirName);
_dbg_assert_msg_(WII_IPC_FILEIO, File::IsDirectory(DirName), "FS: CREATE_DIR %s failed", DirName.c_str());
return FS_RESULT_OK;
}
@ -359,13 +359,13 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
u8 GroupPerm = 0x3; // read/write
u8 OtherPerm = 0x3; // read/write
u8 Attributes = 0x00; // no attributes
if (File::IsDirectory(Filename.c_str()))
if (File::IsDirectory(Filename))
{
INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR Directory %s - all permission flags are set", Filename.c_str());
}
else
{
if (File::Exists(Filename.c_str()))
if (File::Exists(Filename))
{
INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR %s - all permission flags are set", Filename.c_str());
}
@ -401,11 +401,11 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
std::string Filename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn+Offset), 64);
Offset += 64;
if (File::Delete(Filename.c_str()))
if (File::Delete(Filename))
{
INFO_LOG(WII_IPC_FILEIO, "FS: DeleteFile %s", Filename.c_str());
}
else if (File::DeleteDir(Filename.c_str()))
else if (File::DeleteDir(Filename))
{
INFO_LOG(WII_IPC_FILEIO, "FS: DeleteDir %s", Filename.c_str());
}
@ -430,16 +430,16 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
Offset += 64;
// try to make the basis directory
File::CreateFullPath(FilenameRename.c_str());
File::CreateFullPath(FilenameRename);
// if there is already a file, delete it
if (File::Exists(FilenameRename.c_str()))
if (File::Exists(FilenameRename))
{
File::Delete(FilenameRename.c_str());
File::Delete(FilenameRename);
}
// finally try to rename the file
if (File::Rename(Filename.c_str(), FilenameRename.c_str()))
if (File::Rename(Filename, FilenameRename))
{
INFO_LOG(WII_IPC_FILEIO, "FS: Rename %s to %s", Filename.c_str(), FilenameRename.c_str());
}
@ -475,15 +475,15 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
DEBUG_LOG(WII_IPC_FILEIO, " Attributes: 0x%02x", Attributes);
// check if the file already exist
if (File::Exists(Filename.c_str()))
if (File::Exists(Filename))
{
WARN_LOG(WII_IPC_FILEIO, "\tresult = FS_RESULT_EXISTS");
return FS_FILE_EXIST;
}
// create the file
File::CreateFullPath(Filename.c_str()); // just to be sure
bool Result = File::CreateEmptyFile(Filename.c_str());
File::CreateFullPath(Filename); // just to be sure
bool Result = File::CreateEmptyFile(Filename);
if (!Result)
{
ERROR_LOG(WII_IPC_FILEIO, "CWII_IPC_HLE_Device_fs: couldn't create new file");

View File

@ -201,25 +201,21 @@ bool BeginRecordingInput(int controllers)
if(g_playMode != MODE_NONE || controllers == 0 || g_recordfd != NULL)
return false;
const char *filename = g_recordFile.c_str();
if(File::Exists(filename))
File::Delete(filename);
if(File::Exists(g_recordFile))
File::Delete(g_recordFile);
if (Core::isRunning())
{
std::string tmpStateFilename = g_recordFile;
tmpStateFilename.append(".sav");
const char *stateFilename = tmpStateFilename.c_str();
const std::string stateFilename = g_recordFile + ".sav";
if(File::Exists(stateFilename))
File::Delete(stateFilename);
State_SaveAs(stateFilename);
State_SaveAs(stateFilename.c_str());
g_bRecordingFromSaveState = true;
}
g_recordfd = fopen(filename, "wb");
g_recordfd = fopen(g_recordFile.c_str(), "wb");
if(!g_recordfd) {
PanicAlertT("Error opening file %s for recording", filename);
PanicAlertT("Error opening file %s for recording", g_recordFile.c_str());
return false;
}
@ -360,8 +356,8 @@ bool PlayInput(const char *filename)
DTMHeader header;
File::Delete(g_recordFile.c_str());
File::Copy(filename, g_recordFile.c_str());
File::Delete(g_recordFile);
File::Copy(filename, g_recordFile);
g_recordfd = fopen(g_recordFile.c_str(), "r+b");
if(!g_recordfd)
@ -377,9 +373,8 @@ bool PlayInput(const char *filename)
// Load savestate (and skip to frame data)
if(header.bFromSaveState)
{
std::string stateFilename = filename;
stateFilename.append(".sav");
if(File::Exists(stateFilename.c_str()))
const std::string stateFilename = std::string(filename) + ".sav";
if(File::Exists(stateFilename))
Core::SetStateFileName(stateFilename);
g_bRecordingFromSaveState = true;
}
@ -445,8 +440,8 @@ void LoadInput(const char *filename)
if (g_recordfd)
fclose(g_recordfd);
File::Delete(g_recordFile.c_str());
File::Copy(filename, g_recordFile.c_str());
File::Delete(g_recordFile);
File::Copy(filename, g_recordFile);
g_recordfd = fopen(g_recordFile.c_str(), "r+b");
fseeko(g_recordfd, 0, SEEK_END);
@ -569,8 +564,8 @@ void EndPlayInput(bool cont)
// if playback ends before the end of the file.
SaveRecording(g_tmpRecordFile.c_str());
fclose(g_recordfd);
File::Delete(g_recordFile.c_str());
File::Copy(g_tmpRecordFile.c_str(), g_recordFile.c_str());
File::Delete(g_recordFile);
File::Copy(g_tmpRecordFile, g_recordFile);
g_recordfd = fopen(g_recordFile.c_str(), "r+b");
fseeko(g_recordfd, 0, SEEK_END);
g_playMode = MODE_RECORDING;
@ -624,7 +619,7 @@ void SaveRecording(const char *filename)
bool success = false;
fclose(g_recordfd);
File::Delete(filename);
success = File::Copy(g_recordFile.c_str(), filename);
success = File::Copy(g_recordFile, filename);
if (success && g_bRecordingFromSaveState)
{
@ -632,7 +627,7 @@ void SaveRecording(const char *filename)
tmpStateFilename.append(".sav");
std::string stateFilename = filename;
stateFilename.append(".sav");
success = File::Copy(tmpStateFilename.c_str(), stateFilename.c_str());
success = File::Copy(tmpStateFilename, stateFilename);
}
if (success /* && !g_bReadOnly*/)

View File

@ -86,7 +86,7 @@ void LoadPatchSection(const char *section, std::vector<Patch> &patches, IniFile
std::string::size_type loc = line.find_first_of('=', 0);
if (loc != std::string::npos)
line.at(loc) = ':';
line[loc] = ':';
std::vector<std::string> items;
SplitString(line, ':', items);

View File

@ -179,12 +179,12 @@ void CompressAndDumpState(saveStruct* saveArg)
Common::SetCurrentThreadName("SaveState thread");
// Moving to last overwritten save-state
if (File::Exists(cur_filename.c_str()))
if (File::Exists(cur_filename))
{
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::Exists(File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav"))
File::Delete((File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav"));
if (!File::Rename(cur_filename.c_str(), (File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav").c_str()))
if (!File::Rename(cur_filename, File::GetUserPath(D_STATESAVES_IDX) + "lastState.sav"))
Core::DisplayMessage("Failed to move previous state to state undo backup", 1000);
}
@ -388,8 +388,8 @@ void LoadStateCallback(u64 userdata, int cyclesLate)
delete[] buffer;
if (File::Exists(StringFromFormat("%s.dtm", cur_filename.c_str()).c_str()))
Frame::LoadInput(StringFromFormat("%s.dtm", cur_filename.c_str()).c_str());
if (File::Exists(cur_filename + ".dtm"))
Frame::LoadInput((cur_filename + ".dtm").c_str());
else if (!Frame::IsRecordingInputFromSaveState())
Frame::EndPlayInput(false);