<commit_before>#include "cfgFunc.h"
#include "spu.h"
#include "setting.h"
#include "base-effect.h"
#include "helper.h"

#include "tab_select_effect.h"

#include "ff.h"

#include <stdint.h>

void openFile(FIL* fil, uint32_t configNumber, uint32_t mode){
    char buf[32] = "0:/configK";
    
    if(configNumber < 0 || configNumber > 3){
        fil = NULL;
        return;
    }

    buf[9] = configNumber + 48;
    if(mode){
        f_unlink(buf);
        do{
            vTaskDelay(50 / portTICK_PERIOD_MS);
        }while(f_open(fil, buf, FA_OPEN_ALWAYS | FA_CREATE_ALWAYS | FA_WRITE) != FR_OK);
    }else{
        do{
            vTaskDelay(50 / portTICK_PERIOD_MS);
        }while(f_open(fil, buf, FA_OPEN_ALWAYS | FA_READ) != FR_OK);
    }
}

void SaveStageSetting(uint32_t saveSlot){
    FIL fil;
    uint32_t i;

    openFile(&fil, saveSlot, 0);
<commit_msg>Fix bug on opening file in SaveConfig<commit_after>#include "cfgFunc.h"
#include "spu.h"
#include "setting.h"
#include "base-effect.h"
#include "helper.h"

#include "tab_select_effect.h"

#include "ff.h"

#include <stdint.h>

void openFile(FIL* fil, uint32_t configNumber, uint32_t mode){
    char buf[32] = "0:/configK";
    
    if(configNumber < 0 || configNumber > 3){
        fil = NULL;
        return;
    }

    buf[9] = configNumber + 48;
    if(mode){
        f_unlink(buf);
        do{
            vTaskDelay(50 / portTICK_PERIOD_MS);
        }while(f_open(fil, buf, FA_OPEN_ALWAYS | FA_CREATE_ALWAYS | FA_WRITE) != FR_OK);
    }else{
        do{
            vTaskDelay(50 / portTICK_PERIOD_MS);
        }while(f_open(fil, buf, FA_OPEN_ALWAYS | FA_READ) != FR_OK);
    }
}

void SaveStageSetting(uint32_t saveSlot){
    FIL fil;
    uint32_t i;
    f_unlink("0:/tst.txt");
    f_open(&fil, "0:/tst.txt", FA_OPEN_ALWAYS | FA_CREATE_ALWAYS | FA_WRITE);
    f_write(&fil, "XDDDD", 5, NULL);
    f_sync(&fil);
    f_close(&fil);

    openFile(&fil, saveSlot, 1);

{'fraction_non_alphanumeric': 0.14359504132231404, 'fraction_numerical': 0.02324380165289256, 'mean_word_length': 2.881763527054108, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6221876', 'n_tokens_mistral': 802, 'n_tokens_neox': 758, 'n_words': 150}