diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 7fd81d3ae0..1be34355df 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -78,7 +78,7 @@ bool Delete(const char *filename) if (IsDirectory(filename)) return false; #ifdef _WIN32 - DeleteFile(filename); + DeleteFile(SanitizePath(filename).c_str()); #else unlink(filename); #endif @@ -222,7 +222,7 @@ bool DeleteDir(const char *filename) bool Rename(const char *srcFilename, const char *destFilename) { - return (rename(srcFilename, destFilename) == 0); + return (rename(SanitizePath(srcFilename).c_str(), SanitizePath(destFilename).c_str()) == 0); } bool Copy(const char *srcFilename, const char *destFilename) diff --git a/Source/Core/Common/Src/Paths.h b/Source/Core/Common/Src/Paths.h index 9cc0cad349..d2a33fbcc0 100644 --- a/Source/Core/Common/Src/Paths.h +++ b/Source/Core/Common/Src/Paths.h @@ -4,14 +4,13 @@ #ifdef _WIN32 #define PLUGIN_PREFIX "" #define PLUGIN_SUFFIX ".dll" -#define DIR_SEP "\\" -#define DIR_SEP_CHR '\\' #else #define PLUGIN_PREFIX "lib" #define PLUGIN_SUFFIX ".so" +#endif + #define DIR_SEP "/" #define DIR_SEP_CHR '/' -#endif #define PLUGINS_DIR "Plugins" #define ROOT_DIR "." @@ -75,7 +74,8 @@ //#define GC_USER_USA_DIR FULL_GC_USER_DIR USA_DIR //#define GC_USER_JAP_DIR FULL_GC_USER_DIR JAP_DIR -#define FULL_WII_USER_DIR FULL_USERDATA_DIR WII_USER_DIR DIR_SEP // Currently this is used as the "root" for Wii fs, is that correct? +#define FULL_WII_USER_DIR FULL_USERDATA_DIR WII_USER_DIR DIR_SEP +#define FULL_WII_ROOT_DIR FULL_USERDATA_DIR WII_USER_DIR // This is the "root" for Wii fs, so that it may be used with created devices #define FULL_GAMECONFIG_DIR FULL_USERDATA_DIR GAMECONFIG_DIR DIR_SEP #define FULL_CONFIG_DIR FULL_USERDATA_DIR CONFIG_DIR DIR_SEP diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp index 9d84080958..7ea89e3633 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp @@ -230,7 +230,7 @@ void CopySettingsFile(std::string DeviceName) else Source += "setting-eur.txt"; - std::string Target = FULL_WII_USER_DIR + File::SanitizePath(DeviceName.c_str()); + std::string Target = FULL_WII_ROOT_DIR + DeviceName; // Check if the target dir exists, otherwise create it std::string TargetDir = Target.substr(0, Target.find_last_of(DIR_SEP)); @@ -250,7 +250,7 @@ void CopySettingsFile(std::string DeviceName) void ExecuteCommand(u32 _Address) { bool GenerateReply = false; - u32 erased = 0; + u32 erased = 0; ECommandType Command = static_cast(Memory::Read_U32(_Address)); switch (Command) @@ -409,31 +409,30 @@ void ExecuteCommand(u32 _Address) if (GenerateReply) { // Get device id - u32 DeviceID = Memory::Read_U32(_Address + 8); - IWII_IPC_HLE_Device* pDevice = NULL; + u32 DeviceID = Memory::Read_U32(_Address + 8); + IWII_IPC_HLE_Device* pDevice = NULL; // Get the device from the device map if (DeviceID != 0) { if (g_DeviceMap.find(DeviceID) != g_DeviceMap.end()) pDevice = g_DeviceMap[DeviceID]; - if (pDevice != NULL) { - // Write reply, this will later be executed in Update() - g_ReplyQueue.push(std::pair(_Address, pDevice->GetDeviceName())); - } else { - LOG(WII_IPC_HLE, "IOP: Reply to unknown device ID (DeviceID=%i)", DeviceID); - g_ReplyQueue.push(std::pair(_Address, "unknown")); - } - - if (erased > 0 && erased == DeviceID) - DeleteDeviceByID(DeviceID); + if (pDevice != NULL) { + // Write reply, this will later be executed in Update() + g_ReplyQueue.push(std::pair(_Address, pDevice->GetDeviceName())); + } else { + LOG(WII_IPC_HLE, "IOP: Reply to unknown device ID (DeviceID=%i)", DeviceID); + g_ReplyQueue.push(std::pair(_Address, "unknown")); + } + + if (erased > 0 && erased == DeviceID) + DeleteDeviceByID(DeviceID); } else { - // 0 is ok, as it's used for devices that weren't created yet - g_ReplyQueue.push(std::pair(_Address, "unknown")); + // 0 is ok, as it's used for devices that weren't created yet + g_ReplyQueue.push(std::pair(_Address, "unknown")); } } - } // This is called continuously and WII_IPCInterface::IsReady() is controlled from WII_IPC.cpp. 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 33f0e405ea..401a9b8c43 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 @@ -29,11 +29,11 @@ std::string HLE_IPC_BuildFilename(const char* _pFilename, int _size) char Buffer[128]; memcpy(Buffer, _pFilename, _size); - std::string Filename(FULL_WII_USER_DIR); + std::string Filename(FULL_WII_ROOT_DIR); if (Buffer[1] == '0') - Filename += std::string("title"); // this looks and feel like an hack... + Filename += std::string("/title"); // this looks and feel like an hack... - Filename += File::SanitizePath(Buffer); + Filename += Buffer; return Filename; } 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 86be950cfa..bb63fe6b4b 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 @@ -377,6 +377,10 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B { LOG(WII_IPC_FILEIO, "FS: DeleteFile %s", Filename.c_str()); } + else if (File::DeleteDir(Filename.c_str())) + { + LOG(WII_IPC_FILEIO, "FS: DeleteDir %s", Filename.c_str()); + } else { LOG(WII_IPC_FILEIO, "FS: DeleteFile %s - failed!!!", Filename.c_str());