Merge pull request #2170 from ergo720/format_partition

Added option to clear the cache partitions from the GUI
This commit is contained in:
RadWolfie 2021-03-22 14:51:58 -05:00 committed by GitHub
commit 2d63e89208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 0 deletions

View File

@ -98,6 +98,36 @@ void ClearSymbolCache(const char sStorageLocation[MAX_PATH])
printf("Cleared HLE Cache\n");
}
unsigned ClearCachePartitions()
{
const std::string &partition_path = g_Settings->GetDataLocation() + "\\EmuDisk\\Partition";
std::error_code err;
unsigned has_any_err = 0;
for (int partition_num = 3; partition_num < 6; ++partition_num) {
const std::string &partition = partition_path + std::to_string(partition_num);
for (const auto &directory_entry : std::filesystem::directory_iterator(partition, err)) {
if (err) {
has_any_err |= 1;
}
else {
std::filesystem::remove_all(directory_entry, err);
if (err) {
has_any_err |= 1;
}
}
}
const std::string &partition_bin = partition + ".bin";
std::filesystem::remove(partition_bin, err);
if (err) {
has_any_err |= 1;
}
}
return has_any_err;
}
void WndMain::InitializeSettings()
{
g_Settings->Delete();
@ -1088,6 +1118,22 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
}
break;
case ID_SETTINGS_CLEAR_PARTITIONS:
{
if (m_bIsStarted) {
PopupError(m_hwnd, "Cannot clear the cache partitions while a title is running.");
}
else {
if (ClearCachePartitions()) {
PopupError(m_hwnd, "An errror has occoured while clearing the cache partitions.");
}
else {
PopupInfo(m_hwnd, "Cleared the cache partitions.");
}
}
}
break;
case ID_SETTINGS_INITIALIZE:
{
PopupReturn ret = PopupWarningEx(m_hwnd, PopupButtons::YesNo, PopupReturn::No,

View File

@ -691,6 +691,7 @@ BEGIN
MENUITEM "&Clear entire Symbol Cache", ID_CACHE_CLEARHLECACHE_ALL,MFT_STRING,MFS_ENABLED
MENUITEM "&Rescan title Symbol Cache", ID_CACHE_CLEARHLECACHE_CURRENT,MFT_STRING,MFS_ENABLED
END
MENUITEM "Clear Cache Partitions", ID_SETTINGS_CLEAR_PARTITIONS,MFT_STRING,MFS_ENABLED
MENUITEM "", -1, MFT_SEPARATOR
POPUP "Experimental", 65535,MFT_STRING,MFS_ENABLED
BEGIN

View File

@ -304,6 +304,7 @@
#define ID_SETTINGS_CACHE 40083
#define ID_CACHE_CLEARHLECACHE_ALL 40084
#define ID_CACHE_CLEARHLECACHE_CURRENT 40085
#define ID_SETTINGS_CLEAR_PARTITIONS 40086
#define ID_SETTINGS_HACKS 40088
#define ID_HACKS_DISABLEPIXELSHADERS 40089
#define ID_LED 40090