Added detection if multiple packs found

This commit is contained in:
Niklas080208
2026-02-03 22:15:17 +01:00
parent fdad061616
commit 4a4147686e
6 changed files with 639 additions and 465 deletions

View File

@@ -9,20 +9,27 @@
#include "deletion_lists_clean.h"
#include "fs.h"
#include "gfx.h"
#include "version.h"
#include <libs/fatfs/ff.h>
#include <string.h>
#undef COLOR_CYAN
#undef COLOR_WHITE
#undef COLOR_GREEN
#undef COLOR_RED
#undef COLOR_YELLOW
#undef COLOR_ORANGE
#define COLOR_CYAN 0xFF00FFFF
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_GREEN 0xFF00FF00
#define COLOR_RED 0xFFFF0000
#define COLOR_YELLOW 0xFFFFDD00
#define COLOR_ORANGE 0xFF00A5FF
#define set_color install_set_color
#define check_and_clear_screen_if_needed install_check_and_clear_screen_if_needed
#define path_exists install_path_exists
#define count_directory_items install_count_directory_items
// Clean mode: Backup user data
int clean_mode_backup(void) {
@@ -109,3 +116,55 @@ int clean_mode_restore(void) {
int clean_mode_install(omninx_variant_t variant) {
return update_mode_install(variant);
}
// Remove other staging directories (OmniNX Standard/Light/OC) that exist on SD
int cleanup_other_staging_directories(omninx_variant_t installed_variant) {
static const omninx_variant_t all_variants[] = { VARIANT_STANDARD, VARIANT_LIGHT, VARIANT_OC };
const int n = sizeof(all_variants) / sizeof(all_variants[0]);
int last_res = FR_OK;
for (int i = 0; i < n; i++) {
omninx_variant_t v = all_variants[i];
if (v == installed_variant)
continue;
const char *staging = get_staging_path(v);
if (!staging || !path_exists(staging))
continue;
check_and_clear_screen_if_needed();
set_color(COLOR_YELLOW);
gfx_printf("\nEntferne weiteren Installationsordner...\n");
set_color(COLOR_WHITE);
int total = count_directory_items(staging);
u32 start_x, start_y;
gfx_con_getpos(&start_x, &start_y);
const char *folder_name = strrchr(staging, '/');
if (folder_name) folder_name++;
else folder_name = staging;
set_color(COLOR_CYAN);
gfx_printf(" Loesche: %s [ 0%%] (0/%d)", folder_name, total);
set_color(COLOR_WHITE);
int deleted = 0;
int last_percent = -1;
int res = folder_delete_progress_recursive(staging, &deleted, total, start_x, start_y, folder_name, &last_percent);
gfx_con_setpos(start_x, start_y);
if (res == FR_OK) {
set_color(COLOR_GREEN);
gfx_printf(" Loesche: %s [100%%] (%d/%d) - Fertig!\n", folder_name, deleted, total);
set_color(COLOR_WHITE);
} else {
set_color(COLOR_ORANGE);
gfx_printf(" Loesche: %s - Fehlgeschlagen!\n", folder_name);
gfx_printf(" [WARN] Ordner konnte nicht entfernt werden (err=%d)\n", res);
set_color(COLOR_WHITE);
}
last_res = res;
}
return last_res;
}