diff options
| author | nakeee <nakeee@gmail.com> | 2008-11-30 13:39:11 +0000 |
|---|---|---|
| committer | nakeee <nakeee@gmail.com> | 2008-11-30 13:39:11 +0000 |
| commit | b46152cdbdd9329969b6da761e9b5c826990bab5 (patch) | |
| tree | d363499de68623bba7e10ed9bb7eeaa7355a5058 /Source/Core | |
| parent | 1c3415118288f8ee9ed189a1b8f70a2d598b0745 (diff) | |
few more small fixes
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1337 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/Src/FileUtil.cpp | 15 | ||||
| -rw-r--r-- | Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp | 79 |
2 files changed, 54 insertions, 40 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 8342c0baed..747bbda2af 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -83,11 +83,16 @@ bool Delete(const char *filename) std::string SanitizePath(const char *filename)
{
- std::string copy = filename;
- for (size_t i = 0; i < copy.size(); i++)
- if (copy[i] == '/')
- copy[i] = '\\';
- return copy;
+
+ 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;
}
void Launch(const char *filename)
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp index 1de4ad678e..ff90721667 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp @@ -74,47 +74,56 @@ CWII_IPC_HLE_Device_FileIO::Close(u32 _CommandAddress) bool
CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
{
- //LOG(WII_IPC_FILEIO, "===================================================================");
-
- u32 ReturnValue = 0;
-
- const char Modes[][128] =
+ //LOG(WII_IPC_FILEIO, "===================================================================");
+
+ u32 ReturnValue = 0;
+
+ const char Modes[][128] =
{
- { "Unk Mode" },
- { "Read only" },
- { "Write only" },
- { "Read and Write" }
+ { "Unk Mode" },
+ { "Read only" },
+ { "Write only" },
+ { "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()))
- {
- 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;
- }
- }
-
- if (m_pFileHandle != NULL)
- {
- m_FileLength = File::GetSize(m_Filename.c_str());
- ReturnValue = GetDeviceID();
- }
- else
- {
- LOG(WII_IPC_FILEIO, " failed - File doesn't exist");
+ 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())) {
+ 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;
+ }
+
+
+ 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;
}
-
+
Memory::Write_U32(ReturnValue, _CommandAddress+4);
- //LOG(WII_IPC_FILEIO, "===================================================================");
+ //LOG(WII_IPC_FILEIO, "===================================================================");
return true;
}
|
