mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-29 00:33:01 +00:00
Implement vfs::host::rename
With spurious access error workaround
This commit is contained in:
parent
3354f068fc
commit
9736773c04
@ -453,7 +453,7 @@ error_code cellGameContentPermit(vm::ptr<char[CELL_GAME_PATH_MAX]> contentInfoPa
|
|||||||
// Make temporary directory persistent
|
// Make temporary directory persistent
|
||||||
const auto vdir = vfs::get(dir);
|
const auto vdir = vfs::get(dir);
|
||||||
|
|
||||||
if (fs::rename(prm->temp, vdir, false))
|
if (vfs::host::rename(prm->temp, vdir, false))
|
||||||
{
|
{
|
||||||
cellGame.success("cellGameContentPermit(): directory '%s' has been created", dir);
|
cellGame.success("cellGameContentPermit(): directory '%s' has been created", dir);
|
||||||
}
|
}
|
||||||
|
@ -934,19 +934,16 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
|
|||||||
fs::remove_all(old_path, false);
|
fs::remove_all(old_path, false);
|
||||||
|
|
||||||
// Backup old savedata
|
// Backup old savedata
|
||||||
while (!fs::rename(dir_path, old_path, true))
|
if (!vfs::host::rename(dir_path, old_path, true))
|
||||||
{
|
{
|
||||||
// Try to ignore access error in order to prevent spurious failure
|
fmt::throw_exception("Failed to move directory %s (%s)", dir_path, fs::g_tls_error);
|
||||||
if (Emu.IsStopped() || fs::g_tls_error != fs::error::acces)
|
|
||||||
fmt::throw_exception("Failed to move directory %s (%s)", dir_path, fs::g_tls_error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit new savedata
|
// Commit new savedata
|
||||||
while (!fs::rename(new_path, dir_path, false))
|
if (!vfs::host::rename(new_path, dir_path, false))
|
||||||
{
|
{
|
||||||
// TODO: handle the case when only commit failed at the next save load
|
// TODO: handle the case when only commit failed at the next save load
|
||||||
if (Emu.IsStopped() || fs::g_tls_error != fs::error::acces)
|
fmt::throw_exception("Failed to move directory %s (%s)", new_path, fs::g_tls_error);
|
||||||
fmt::throw_exception("Failed to move directory %s (%s)", new_path, fs::g_tls_error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove backup again (TODO: may be changed to persistent backup implementation)
|
// Remove backup again (TODO: may be changed to persistent backup implementation)
|
||||||
|
@ -774,7 +774,7 @@ error_code sys_fs_rename(vm::cptr<char> from, vm::cptr<char> to)
|
|||||||
return CELL_ENOTMOUNTED;
|
return CELL_ENOTMOUNTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs::rename(local_from, local_to, false))
|
if (!vfs::host::rename(local_from, local_to, false))
|
||||||
{
|
{
|
||||||
switch (auto error = fs::g_tls_error)
|
switch (auto error = fs::g_tls_error)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "IdManager.h"
|
#include "IdManager.h"
|
||||||
|
#include "System.h"
|
||||||
#include "VFS.h"
|
#include "VFS.h"
|
||||||
|
|
||||||
#include "Utilities/mutex.h"
|
#include "Utilities/mutex.h"
|
||||||
@ -447,3 +448,17 @@ std::string vfs::unescape(std::string_view path)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool vfs::host::rename(const std::string& from, const std::string& to, bool overwrite)
|
||||||
|
{
|
||||||
|
while (!fs::rename(from, to, overwrite))
|
||||||
|
{
|
||||||
|
// Try to ignore access error in order to prevent spurious failure
|
||||||
|
if (Emu.IsStopped() || fs::g_tls_error != fs::error::acces)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -17,4 +17,11 @@ namespace vfs
|
|||||||
|
|
||||||
// Invert escape operation
|
// Invert escape operation
|
||||||
std::string unescape(std::string_view path);
|
std::string unescape(std::string_view path);
|
||||||
|
|
||||||
|
// Functions in this namespace operate on host filepaths, similar to fs::
|
||||||
|
namespace host
|
||||||
|
{
|
||||||
|
// Call fs::rename with retry on access error
|
||||||
|
bool rename(const std::string& from, const std::string& to, bool overwrite);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user