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 b777a9a05a..8e6003e253 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 @@ -21,7 +21,6 @@ #include "WII_IPC_HLE_Device_FileIO.h" - std::string HLE_IPC_BuildFilename(const char* _pFilename, int _size) { char Buffer[128]; @@ -60,6 +59,8 @@ CWII_IPC_HLE_Device_FileIO::~CWII_IPC_HLE_Device_FileIO() bool CWII_IPC_HLE_Device_FileIO::Close(u32 _CommandAddress) { + LOG(WII_IPC_FILEIO, "FileIO: Close %s", GetDeviceName().c_str()); + Memory::Write_U32(0, _CommandAddress+4); return true; } @@ -81,12 +82,15 @@ CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode) m_Filename = std::string(HLE_IPC_BuildFilename(GetDeviceName().c_str(), 64)); - switch(_Mode) + if (File::Exists(m_Filename.c_str())) { - 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; + switch(_Mode) + { + 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) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h index 80cf72257b..9deb3b65c2 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h @@ -14,6 +14,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ + #ifndef _WII_IPC_HLE_DEVICE_FILEIO_H_ #define _WII_IPC_HLE_DEVICE_FILEIO_H_ diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp index cb001a7d9e..7f126ef63e 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp @@ -64,13 +64,9 @@ bool CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode) char* pTitleID = (char*)&TitleID; char Path[260+1]; - sprintf(Path, "Wii/title/00010000/%02x%02x%02x%02x", (u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]); - if (!File::IsDirectory(Path)) - { - File::CreateDir(Path); - sprintf(Path, "Wii/title/00010000/%02x%02x%02x%02x/data", (u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]); - File::CreateDir(Path); - } + sprintf(Path, "Wii/title/00010000/%02x%02x%02x%02x/data/nocopy/", (u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]); + + CreateDirectoryStruct(Path); } Memory::Write_U32(GetDeviceID(), _CommandAddress+4); @@ -186,8 +182,15 @@ bool CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress) Extensions.push_back("*.*"); CFileSearch FileSearch(Extensions, Directories); - fsBlock = (u32)FileSearch.GetFileNames().size(); - iNodes = fsBlock * 10; + + u64 overAllSize = 0; + for (size_t i=0; i