Jim M. schrieb:
> Du rufst die Funktion rekursiv auf, aber static char lfn[_MAX_LFN
> + 1];
>
> ist IMO nicht-reentrant, weil Dir der Unteraufruf den langen Namen
> überschreibt.
Weenn ich das jetzt so schreibe wie von ihnen vorgeschlagen, wird's auch
nicht richtig gelesen
1 | static char lfn[_MAX_LFN + 1];
|
2 |
|
3 |
|
4 | //###################################################################################
|
5 | FRESULT scan_files_temp (char* path /* Start node to be scanned (also used as work area) */)
|
6 | //###################################################################################
|
7 | {
|
8 | FRESULT res;
|
9 | FILINFO fno;
|
10 | DIR dir;
|
11 | int i;
|
12 | char *fn; /* This function is assuming non-Unicode cfg. */
|
13 | #if _USE_LFN
|
14 | //static char lfn[_MAX_LFN + 1];
|
15 | fno.lfname = lfn;
|
16 | fno.lfsize = sizeof lfn;
|
17 | #endif
|
18 |
|
19 |
|
20 | res = f_opendir(&dir, path); /* Open the directory */
|
21 | if (res == FR_OK) {
|
22 | i = strlen(path);
|
23 |
|
24 |
|
25 | for (;;) {
|
26 |
|
27 | res = f_readdir(&dir, &fno); /* Read a directory item */
|
28 | if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
|
29 | if (fno.fname[0] == '.') continue; /* Ignore dot entry */
|
30 | #if _USE_LFN
|
31 | fn = *fno.lfname ? fno.lfname : fno.fname;
|
32 | #else
|
33 | fn = fno.fname;
|
34 | #endif
|
35 | if (fno.fattrib & AM_DIR)
|
36 | { /* It is a directory */
|
37 | sprintf(&path[i], "/%s", fn);
|
38 | res = scan_files_temp(path);
|
39 |
|
40 | strcpy(TEMP_directory[Temp_historyzaehler],fn);
|
41 |
|
42 |
|
43 |
|
44 | if (res != FR_OK) break;
|
45 | path[i] = 0;
|
46 | Temp_historyzaehler ++;
|
47 |
|
48 | }
|
49 |
|
50 | else
|
51 | {
|
52 | }
|
53 | }
|
54 | }
|
55 | return res;
|
56 | }
|