it seems that "rename" overwrites files...

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1086 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
fires.gc 2008-11-06 22:01:09 +00:00
parent 2e4cde02fd
commit 03d5443636
3 changed files with 19 additions and 5 deletions

View File

@ -163,6 +163,11 @@ bool DeleteDir(const char *filename)
#endif
}
bool Rename(const char *srcFilename, const char *destFilename)
{
return (rename(srcFilename, destFilename) == 0);
}
std::string GetUserDirectory()
{
#ifdef _WIN32

View File

@ -43,6 +43,7 @@ bool IsDirectory(const char *filename);
bool CreateDir(const char *filename);
bool Delete(const char *filename);
bool DeleteDir(const char *filename);
bool Rename(const char *srcFilename, const char *destFilename);
u64 GetSize(const char *filename);
std::string GetUserDirectory();
bool CreateEmptyFile(const char *filename);

View File

@ -328,9 +328,17 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
std::string FilenameRename = HLE_IPC_BuildFilename((const char*)Memory::GetPointer(_BufferIn+Offset), 64);
Offset += 64;
// F|RES: i think that we dont need this - CreateDirectoryStruct(Filename);
// try to make the basis directory
CreateDirectoryStruct(Filename);
if (rename(Filename.c_str(), FilenameRename.c_str()) == 0)
// if there is already a filedelete it
if (File::Exists(FilenameRename.c_str()))
{
File::Delete(FilenameRename.c_str());
}
// finally try to rename the file
if (File::Rename(Filename.c_str(), FilenameRename.c_str()))
{
LOG(WII_IPC_FILEIO, "FS: Rename %s to %s", Filename.c_str(), FilenameRename.c_str());
}