Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of Wii NAND's /tmp directory during savestate loads. #3798

Merged
merged 2 commits into from
Apr 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions Source/Core/Common/FileUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ FSTEntry ScanDirectoryTree(const std::string& directory, bool recursive)
bool DeleteDirRecursively(const std::string& directory)
{
INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str());
bool success = true;

#ifdef _WIN32
// Find the first file in the directory.
WIN32_FIND_DATA ffd;
Expand Down Expand Up @@ -568,22 +570,16 @@ bool DeleteDirRecursively(const std::string& directory)
{
if (!DeleteDirRecursively(newPath))
{
#ifndef _WIN32
closedir(dirp);
#endif

return false;
success = false;
break;
}
}
else
{
if (!File::Delete(newPath))
{
#ifndef _WIN32
closedir(dirp);
#endif

return false;
success = false;
break;
}
}

Expand All @@ -594,9 +590,10 @@ bool DeleteDirRecursively(const std::string& directory)
}
closedir(dirp);
#endif
File::DeleteDir(directory);
if (success)
File::DeleteDir(directory);

return true;
return success;
}

// Create directory and copy contents (does not overwrite existing files)
Expand Down
17 changes: 10 additions & 7 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ void DoState(PointerWrap &p)
p.Do(reply_queue);
p.Do(last_reply_time);

if (p.GetMode() == PointerWrap::MODE_READ)
{
// We need to make sure all file handles are closed so WII_IPC_Devices_fs::DoState can successfully re-create /tmp
for (u32 i = 0; i < IPC_MAX_FDS; i++)
g_FdMap[i].reset();
}

for (const auto& entry : g_DeviceMap)
{
if (entry.second->IsHardware())
Expand All @@ -280,7 +287,7 @@ void DoState(PointerWrap &p)

if (p.GetMode() == PointerWrap::MODE_READ)
{
for (u32 i=0; i<IPC_MAX_FDS; i++)
for (u32 i=0; i < IPC_MAX_FDS; i++)
{
u32 exists = 0;
p.Do(exists);
Expand All @@ -300,13 +307,9 @@ void DoState(PointerWrap &p)
g_FdMap[i]->DoState(p);
}
}
else
{
g_FdMap[i].reset();
}
}

for (u32 i=0; i<ES_MAX_COUNT; i++)
for (u32 i=0; i < ES_MAX_COUNT; i++)
{
p.Do(es_inuse[i]);
u32 handleID = es_handles[i]->GetDeviceID();
Expand Down Expand Up @@ -337,7 +340,7 @@ void DoState(PointerWrap &p)
}
}

for (u32 i=0; i<ES_MAX_COUNT; i++)
for (u32 i=0; i < ES_MAX_COUNT; i++)
{
p.Do(es_inuse[i]);
u32 handleID = es_handles[i]->GetDeviceID();
Expand Down