SD card settings folder: Use f_stat to determine if directory is present

This commit is contained in:
Mario Hüttel 2020-08-21 00:06:56 +02:00
parent 04994bff51
commit 0395cd19d4

View File

@ -59,19 +59,17 @@ static int create_controller_folder(void)
char foldername[48]; char foldername[48];
int ret = -1; int ret = -1;
FRESULT filesystem_result; FRESULT filesystem_result;
DIR folder; FILINFO fno;
get_controller_folder_path(foldername, sizeof(foldername)); get_controller_folder_path(foldername, sizeof(foldername));
/* Check if folder is present */ /* Check if folder is present */
filesystem_result = f_opendir(&folder, foldername); filesystem_result = f_stat(foldername, &fno);
if (filesystem_result == FR_OK) { if (filesystem_result == FR_OK && fno.fattrib & AM_DIR) {
ret = 0; ret = 0;
f_closedir(&folder);
} else { } else {
filesystem_result = f_mkdir(foldername); filesystem_result = f_mkdir(foldername);
if (filesystem_result == FR_OK) { if (filesystem_result == FR_OK) {
f_closedir(&folder);
ret = 1; ret = 1;
} else { } else {
ret = -1; ret = -1;