1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
31
32
33
34
35
36
37
38
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
65
69
70
71
72
87
88
89
90
91
92
93
94
99
114
115
116
122
123
124
125
126
127
128
132
144
145
146
149
150
/* ... */
#include "filebrowser_app.h"
#include <string.h>
/* ... */
/* ... */
Includes
/* ... */
uint8_t FILEMGR_ParseDisks (char *path, FILELIST_FileTypeDef *list)
{
FRESULT res;
FILINFO fno;
DIR dir;
char *fn;
res = f_opendir(&dir, path);
list->ptr = 0;
if (res == FR_OK)
{
while (1)
{
res = f_readdir(&dir, &fno);
if (res != FR_OK || fno.fname[0] == 0)
{
break;
}if (res != FR_OK || fno.fname[0] == 0) { ... }
if (fno.fname[0] == '.')
{
continue;
}if (fno.fname[0] == '.') { ... }
fn = fno.fname;
if (list->ptr < FILEMGR_LIST_DEPDTH)
{
if ((fno.fattrib & AM_DIR) == AM_DIR)
{
strncpy((char *)list->file[list->ptr].name, (char *)fn, FILEMGR_FILE_NAME_SIZE);
list->file[list->ptr].type = FILETYPE_DIR;
list->ptr++;
}if ((fno.fattrib & AM_DIR) == AM_DIR) { ... }
else
{
strncpy((char *)list->file[list->ptr].name, (char *)fn, FILEMGR_FILE_NAME_SIZE);
list->file[list->ptr].type = FILETYPE_FILE;
list->ptr++;
}else { ... }
}if (list->ptr < FILEMGR_LIST_DEPDTH) { ... }
}while (1) { ... }
f_closedir(&dir);
}if (res == FR_OK) { ... }
return res;
}{ ... }
/* ... */
void FILEMGR_GetParentDir (char *dir)
{
uint16_t idx = FILEMGR_FULL_PATH_SIZE;
for ( ; idx > 0; idx --)
{
if (dir [idx] == '/')
{
dir [idx + 1] = 0;
break;
}if (dir [idx] == '/') { ... }
dir [idx + 1] = 0;
}for (; idx > 0; idx --) { ... }
}{ ... }
/* ... */
void FILEMGR_GetFileOnly (char *file, char *path)
{
char *baseName1, *baseName2;
baseName1 = strrchr(path,'/');
baseName2 = strrchr(path,':');
if(baseName1++)
{
strcpy(file, baseName1);
}if (baseName1++) { ... }
else
{
if (baseName2++)
{
strcpy(file, baseName2);
}if (baseName2++) { ... }
else
{
strcpy(file, path);
}else { ... }
}else { ... }
}{ ... }
/* ... */
/* ... */