SD card settings folder: Use f_stat to determine if directory is present
This commit is contained in:
parent
04994bff51
commit
0395cd19d4
@ -59,19 +59,17 @@ static int create_controller_folder(void)
|
||||
char foldername[48];
|
||||
int ret = -1;
|
||||
FRESULT filesystem_result;
|
||||
DIR folder;
|
||||
FILINFO fno;
|
||||
|
||||
get_controller_folder_path(foldername, sizeof(foldername));
|
||||
|
||||
/* Check if folder is present */
|
||||
filesystem_result = f_opendir(&folder, foldername);
|
||||
if (filesystem_result == FR_OK) {
|
||||
filesystem_result = f_stat(foldername, &fno);
|
||||
if (filesystem_result == FR_OK && fno.fattrib & AM_DIR) {
|
||||
ret = 0;
|
||||
f_closedir(&folder);
|
||||
} else {
|
||||
filesystem_result = f_mkdir(foldername);
|
||||
if (filesystem_result == FR_OK) {
|
||||
f_closedir(&folder);
|
||||
ret = 1;
|
||||
} else {
|
||||
ret = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user