1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

Wipe clean VSH's temporary directory of choice at boot

This commit is contained in:
Eladash 2022-01-07 19:16:03 +02:00 committed by Ivan
parent 285322982f
commit 1088375b38
7 changed files with 15 additions and 6 deletions

View File

@ -1788,7 +1788,7 @@ const std::string& fs::get_temp_dir()
return s_dir;
}
bool fs::remove_all(const std::string& path, bool remove_root)
bool fs::remove_all(const std::string& path, bool remove_root, bool is_no_dir_ok)
{
if (const auto root_dir = dir(path))
{
@ -1817,7 +1817,7 @@ bool fs::remove_all(const std::string& path, bool remove_root)
}
else
{
return false;
return is_no_dir_ok;
}
if (remove_root)

View File

@ -648,7 +648,7 @@ namespace fs
};
// Delete directory and all its contents recursively
bool remove_all(const std::string& path, bool remove_root = true);
bool remove_all(const std::string& path, bool remove_root = true, bool is_no_dir_ok = false);
// Get size of all files recursively
u64 get_dir_size(const std::string& path, u64 rounding_alignment = 1);

View File

@ -381,7 +381,15 @@ void Emulator::Init(bool add_only)
// Limit cache size
if (!is_exitspawn && g_cfg.vfs.limit_cache_size)
{
rpcs3::cache::limit_cache_size();
}
// Wipe clean VSH's temporary directory of choice
if (g_cfg.vfs.empty_hdd0_tmp && !is_exitspawn && !fs::remove_all(dev_hdd0 + "tmp/", false, true))
{
sys_log.error("Could not clean /dev_hdd0/tmp/ (%s)", fs::g_tls_error);
}
}
void Emulator::SetUsr(const std::string& user)

View File

@ -96,7 +96,7 @@ namespace rpcs3::cache
break;
}
if (is_dir ? !fs::remove_all(name, true) : !fs::remove_file(name))
if (is_dir ? !fs::remove_all(name, true, true) : !fs::remove_file(name))
{
sys_log.error("Could not remove cache directory '%s' item '%s' (%s)", cache_location, item.name, fs::g_tls_error);
break;

View File

@ -94,6 +94,7 @@ struct cfg_root : cfg::node
cfg::_bool limit_cache_size{ this, "Limit disk cache size", false };
cfg::_int<0, 10240> cache_max_size{ this, "Disk cache maximum size (MB)", 5120 };
cfg::_bool empty_hdd0_tmp{ this, "Empty /dev_hdd0/tmp/", true };
} vfs{ this };

View File

@ -56,7 +56,7 @@ bool TRPLoader::Install(std::string_view dest, bool /*show*/)
if (success)
{
success = fs::remove_all(local_path) || !fs::is_dir(local_path);
success = fs::remove_all(local_path, true, true);
if (success)
{

View File

@ -2602,7 +2602,7 @@ void main_window::RemoveDiskCache()
{
const std::string cache_dir = rpcs3::utils::get_hdd1_dir() + "/caches";
if (fs::is_dir(cache_dir) && fs::remove_all(cache_dir, false))
if (fs::remove_all(cache_dir, false))
{
QMessageBox::information(this, tr("Cache Cleared"), tr("Disk cache was cleared successfully"));
}