mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 06:39:14 +01:00
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:
parent
1c34151182
commit
b46152cdbd
@ -83,11 +83,16 @@ bool Delete(const char *filename)
|
|||||||
|
|
||||||
std::string SanitizePath(const char *filename)
|
std::string SanitizePath(const char *filename)
|
||||||
{
|
{
|
||||||
std::string copy = filename;
|
|
||||||
for (size_t i = 0; i < copy.size(); i++)
|
std::string copy = filename;
|
||||||
if (copy[i] == '/')
|
#ifdef _WIN32
|
||||||
copy[i] = '\\';
|
for (size_t i = 0; i < copy.size(); i++)
|
||||||
return copy;
|
if (copy[i] == '/')
|
||||||
|
copy[i] = '\\';
|
||||||
|
#else
|
||||||
|
// Should we do the otherway around?
|
||||||
|
#endif
|
||||||
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launch(const char *filename)
|
void Launch(const char *filename)
|
||||||
|
@ -74,47 +74,56 @@ CWII_IPC_HLE_Device_FileIO::Close(u32 _CommandAddress)
|
|||||||
bool
|
bool
|
||||||
CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
|
CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
|
||||||
{
|
{
|
||||||
//LOG(WII_IPC_FILEIO, "===================================================================");
|
//LOG(WII_IPC_FILEIO, "===================================================================");
|
||||||
|
|
||||||
u32 ReturnValue = 0;
|
u32 ReturnValue = 0;
|
||||||
|
|
||||||
const char Modes[][128] =
|
const char Modes[][128] =
|
||||||
{
|
{
|
||||||
{ "Unk Mode" },
|
{ "Unk Mode" },
|
||||||
{ "Read only" },
|
{ "Read only" },
|
||||||
{ "Write only" },
|
{ "Write only" },
|
||||||
{ "Read and Write" }
|
{ "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));
|
||||||
|
|
||||||
m_Filename = std::string(HLE_IPC_BuildFilename(GetDeviceName().c_str(), 64));
|
LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s)", GetDeviceName().c_str(), Modes[_Mode]);
|
||||||
|
|
||||||
if (File::Exists(m_Filename.c_str()))
|
|
||||||
{
|
if (File::Exists(m_Filename.c_str())) {
|
||||||
switch(_Mode)
|
switch(_Mode)
|
||||||
{
|
{
|
||||||
// Do "r+b" for all writing to avoid truncating the file
|
// Do "r+b" for all writing to avoid truncating the file
|
||||||
case 0x01: m_pFileHandle = fopen(m_Filename.c_str(), "rb"); break;
|
case 0x01:
|
||||||
case 0x02: //m_pFileHandle = fopen(m_Filename.c_str(), "wb"); break;
|
m_pFileHandle = fopen(m_Filename.c_str(), "rb");
|
||||||
case 0x03: m_pFileHandle = fopen(m_Filename.c_str(), "r+b"); break;
|
break;
|
||||||
default: PanicAlert("CWII_IPC_HLE_Device_FileIO: unknown open mode"); break;
|
case 0x02:
|
||||||
}
|
//m_pFileHandle = fopen(m_Filename.c_str(), "wb"); break;
|
||||||
}
|
case 0x03:
|
||||||
|
m_pFileHandle = fopen(m_Filename.c_str(), "r+b");
|
||||||
if (m_pFileHandle != NULL)
|
break;
|
||||||
{
|
default:
|
||||||
m_FileLength = File::GetSize(m_Filename.c_str());
|
PanicAlert("CWII_IPC_HLE_Device_FileIO: unknown open mode");
|
||||||
ReturnValue = GetDeviceID();
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG(WII_IPC_FILEIO, " failed - File doesn't exist");
|
if (m_pFileHandle != NULL) {
|
||||||
|
m_FileLength = File::GetSize(m_Filename.c_str());
|
||||||
|
ReturnValue = GetDeviceID();
|
||||||
|
}
|
||||||
|
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;
|
ReturnValue = -106;
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory::Write_U32(ReturnValue, _CommandAddress+4);
|
Memory::Write_U32(ReturnValue, _CommandAddress+4);
|
||||||
//LOG(WII_IPC_FILEIO, "===================================================================");
|
//LOG(WII_IPC_FILEIO, "===================================================================");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user