From 28ee42995b929b43b9af363a275cd5fb039e64fc Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Thu, 25 Apr 2024 16:09:01 +0100 Subject: [PATCH] Likely incorrect fix for STDIO --- src/menu/cpak_handler.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/menu/cpak_handler.c b/src/menu/cpak_handler.c index bc896a8e..0ec676dd 100644 --- a/src/menu/cpak_handler.c +++ b/src/menu/cpak_handler.c @@ -1,6 +1,6 @@ #include -#include +#include #include "../utils/fs.h" #include "cpak_handler.h" @@ -38,18 +38,20 @@ int cpak_clone_contents_to_file(char *path, uint8_t port) { } } - FIL fil; - UINT bytes_written; - if (f_open(&fil, strip_sd_prefix(path), FA_WRITE | FA_CREATE_ALWAYS) != FR_OK) { + FILE *f; + + if ((f = fopen(strip_fs_prefix(path), "wb")) == NULL) { return CONTROLLER_PAK_ERR_IO; } - FRESULT fwrite_err = f_write(&fil, &cpak_data, sizeof(cpak_data), &bytes_written); - f_close(&fil); + if (fwrite(&cpak_data, 1, sizeof(cpak_data), f) != sizeof(cpak_data)) { + err = 3; + } + fclose(f); - if (fwrite_err) { - return fwrite_err; + if (err) { + return err; } else { return CONTROLLER_PAK_OK;