From 9bb6e66e1a740bafcf64f15d5d5bb88fd6114ea4 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Sat, 20 Jul 2024 15:20:51 +0100 Subject: [PATCH] Create Cpak dir if it does not exist Split the filename defines. --- src/menu/views/joypad_controller_pak.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/menu/views/joypad_controller_pak.c b/src/menu/views/joypad_controller_pak.c index 7992e59e..6b78ee47 100644 --- a/src/menu/views/joypad_controller_pak.c +++ b/src/menu/views/joypad_controller_pak.c @@ -1,24 +1,31 @@ #include "views.h" #include "../cpak_handler.h" +#include "utils/fs.h" #define CPAK_BACKUP_DIRECTORY "/cpak" -#define CPAK_BACKUP_FILE "cpak_backup.pak" +#define CPAK_BACKUP_FILE_PREFIX "cpak_backup" +#define CPAK_BACKUP_FILE_EXT ".pak" static int accessory_is_cpak[4]; static cpak_info_t cpak_info; + static void process (menu_t *menu) { if (menu->actions.enter) { // TODO: handle all ports if (accessory_is_cpak[JOYPAD_PORT_1]) { + // TODO: draw progress bar! // TODO: preferably with the time added to the filename so it does not overwrite the existing one! - path_t *path = path_init(menu->storage_prefix, CPAK_BACKUP_DIRECTORY"/"CPAK_BACKUP_FILE); + path_t *path = path_init(menu->storage_prefix, CPAK_BACKUP_DIRECTORY); + directory_create(path_get(path)); + + path_push(path, CPAK_BACKUP_FILE_PREFIX CPAK_BACKUP_FILE_EXT); + cpak_clone_contents_to_file(path_get(path), JOYPAD_PORT_1); path_free(path); - component_messagebox_draw("Done"); } } @@ -49,7 +56,7 @@ static void draw (menu_t *menu, surface_t *d) { "\n" "\n" "Controller Pak (1).\n" - "Free space: %d blocks. \n", + "Free space: %d/123 pages. \n", cpak_info.free_space ); }