few more small fixes

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1337 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2008-11-30 13:39:11 +00:00
parent 1c34151182
commit b46152cdbd
2 changed files with 53 additions and 39 deletions

View File

@ -83,10 +83,15 @@ bool Delete(const char *filename)
std::string SanitizePath(const char *filename)
{
std::string copy = filename;
#ifdef _WIN32
for (size_t i = 0; i < copy.size(); i++)
if (copy[i] == '/')
copy[i] = '\\';
#else
// Should we do the otherway around?
#endif
return copy;
}

View File

@ -86,30 +86,39 @@ CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
{ "Read and Write" }
};
LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s)", GetDeviceName().c_str(), Modes[_Mode]);
m_Filename = std::string(HLE_IPC_BuildFilename(GetDeviceName().c_str(), 64));
if (File::Exists(m_Filename.c_str()))
{
LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s)", GetDeviceName().c_str(), Modes[_Mode]);
if (File::Exists(m_Filename.c_str())) {
switch(_Mode)
{
// Do "r+b" for all writing to avoid truncating the file
case 0x01: m_pFileHandle = fopen(m_Filename.c_str(), "rb"); break;
case 0x02: //m_pFileHandle = fopen(m_Filename.c_str(), "wb"); break;
case 0x03: m_pFileHandle = fopen(m_Filename.c_str(), "r+b"); break;
default: PanicAlert("CWII_IPC_HLE_Device_FileIO: unknown open mode"); break;
}
case 0x01:
m_pFileHandle = fopen(m_Filename.c_str(), "rb");
break;
case 0x02:
//m_pFileHandle = fopen(m_Filename.c_str(), "wb"); break;
case 0x03:
m_pFileHandle = fopen(m_Filename.c_str(), "r+b");
break;
default:
PanicAlert("CWII_IPC_HLE_Device_FileIO: unknown open mode");
break;
}
if (m_pFileHandle != NULL)
{
if (m_pFileHandle != NULL) {
m_FileLength = File::GetSize(m_Filename.c_str());
ReturnValue = GetDeviceID();
}
else
{
LOG(WII_IPC_FILEIO, " failed - File doesn't exist");
else {
LOG(WII_IPC_FILEIO, "Error opening file %s", m_Filename.c_str());
ReturnValue = -106;
}
} else {
LOG(WII_IPC_FILEIO, "File %s doesn't exist", m_Filename.c_str() );
ReturnValue = -106;
}