replace per-platform DIR_SEP and DIR_SEP_CHR with "/" and '/', cleanup some wii fs things, made CWII_IPC_HLE_Device_fs::ExecuteCommand DELETE_FILE also delete the device if it's a dir.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1406 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2008-12-05 20:00:34 +00:00
parent 116509985a
commit 5c805163bf
5 changed files with 29 additions and 26 deletions

View File

@ -78,7 +78,7 @@ bool Delete(const char *filename)
if (IsDirectory(filename)) if (IsDirectory(filename))
return false; return false;
#ifdef _WIN32 #ifdef _WIN32
DeleteFile(filename); DeleteFile(SanitizePath(filename).c_str());
#else #else
unlink(filename); unlink(filename);
#endif #endif
@ -222,7 +222,7 @@ bool DeleteDir(const char *filename)
bool Rename(const char *srcFilename, const char *destFilename) 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) bool Copy(const char *srcFilename, const char *destFilename)

View File

@ -4,14 +4,13 @@
#ifdef _WIN32 #ifdef _WIN32
#define PLUGIN_PREFIX "" #define PLUGIN_PREFIX ""
#define PLUGIN_SUFFIX ".dll" #define PLUGIN_SUFFIX ".dll"
#define DIR_SEP "\\"
#define DIR_SEP_CHR '\\'
#else #else
#define PLUGIN_PREFIX "lib" #define PLUGIN_PREFIX "lib"
#define PLUGIN_SUFFIX ".so" #define PLUGIN_SUFFIX ".so"
#endif
#define DIR_SEP "/" #define DIR_SEP "/"
#define DIR_SEP_CHR '/' #define DIR_SEP_CHR '/'
#endif
#define PLUGINS_DIR "Plugins" #define PLUGINS_DIR "Plugins"
#define ROOT_DIR "." #define ROOT_DIR "."
@ -75,7 +74,8 @@
//#define GC_USER_USA_DIR FULL_GC_USER_DIR USA_DIR //#define GC_USER_USA_DIR FULL_GC_USER_DIR USA_DIR
//#define GC_USER_JAP_DIR FULL_GC_USER_DIR JAP_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_GAMECONFIG_DIR FULL_USERDATA_DIR GAMECONFIG_DIR DIR_SEP
#define FULL_CONFIG_DIR FULL_USERDATA_DIR CONFIG_DIR DIR_SEP #define FULL_CONFIG_DIR FULL_USERDATA_DIR CONFIG_DIR DIR_SEP

View File

@ -230,7 +230,7 @@ void CopySettingsFile(std::string DeviceName)
else else
Source += "setting-eur.txt"; 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 // Check if the target dir exists, otherwise create it
std::string TargetDir = Target.substr(0, Target.find_last_of(DIR_SEP)); 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) void ExecuteCommand(u32 _Address)
{ {
bool GenerateReply = false; bool GenerateReply = false;
u32 erased = 0; u32 erased = 0;
ECommandType Command = static_cast<ECommandType>(Memory::Read_U32(_Address)); ECommandType Command = static_cast<ECommandType>(Memory::Read_U32(_Address));
switch (Command) switch (Command)
@ -409,31 +409,30 @@ void ExecuteCommand(u32 _Address)
if (GenerateReply) if (GenerateReply)
{ {
// Get device id // Get device id
u32 DeviceID = Memory::Read_U32(_Address + 8); u32 DeviceID = Memory::Read_U32(_Address + 8);
IWII_IPC_HLE_Device* pDevice = NULL; IWII_IPC_HLE_Device* pDevice = NULL;
// Get the device from the device map // Get the device from the device map
if (DeviceID != 0) { if (DeviceID != 0) {
if (g_DeviceMap.find(DeviceID) != g_DeviceMap.end()) if (g_DeviceMap.find(DeviceID) != g_DeviceMap.end())
pDevice = g_DeviceMap[DeviceID]; pDevice = g_DeviceMap[DeviceID];
if (pDevice != NULL) { if (pDevice != NULL) {
// Write reply, this will later be executed in Update() // Write reply, this will later be executed in Update()
g_ReplyQueue.push(std::pair<u32, std::string>(_Address, pDevice->GetDeviceName())); g_ReplyQueue.push(std::pair<u32, std::string>(_Address, pDevice->GetDeviceName()));
} else { } else {
LOG(WII_IPC_HLE, "IOP: Reply to unknown device ID (DeviceID=%i)", DeviceID); LOG(WII_IPC_HLE, "IOP: Reply to unknown device ID (DeviceID=%i)", DeviceID);
g_ReplyQueue.push(std::pair<u32, std::string>(_Address, "unknown")); g_ReplyQueue.push(std::pair<u32, std::string>(_Address, "unknown"));
} }
if (erased > 0 && erased == DeviceID) if (erased > 0 && erased == DeviceID)
DeleteDeviceByID(DeviceID); DeleteDeviceByID(DeviceID);
} else { } else {
// 0 is ok, as it's used for devices that weren't created yet // 0 is ok, as it's used for devices that weren't created yet
g_ReplyQueue.push(std::pair<u32, std::string>(_Address, "unknown")); g_ReplyQueue.push(std::pair<u32, std::string>(_Address, "unknown"));
} }
} }
} }
// This is called continuously and WII_IPCInterface::IsReady() is controlled from WII_IPC.cpp. // This is called continuously and WII_IPCInterface::IsReady() is controlled from WII_IPC.cpp.

View File

@ -29,11 +29,11 @@ std::string HLE_IPC_BuildFilename(const char* _pFilename, int _size)
char Buffer[128]; char Buffer[128];
memcpy(Buffer, _pFilename, _size); memcpy(Buffer, _pFilename, _size);
std::string Filename(FULL_WII_USER_DIR); std::string Filename(FULL_WII_ROOT_DIR);
if (Buffer[1] == '0') 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; return Filename;
} }

View File

@ -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()); 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 else
{ {
LOG(WII_IPC_FILEIO, "FS: DeleteFile %s - failed!!!", Filename.c_str()); LOG(WII_IPC_FILEIO, "FS: DeleteFile %s - failed!!!", Filename.c_str());