|
@@ -56,22 +56,21 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
|
56
|
56
|
// If the entry is a directory and the action is LS_SerialPrint
|
57
|
57
|
if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) {
|
58
|
58
|
|
59
|
|
- // Allocate enough stack space for the full path to a folder, trailing slash, and nul
|
60
|
|
- int len = strlen(prepend) + FILENAME_LENGTH + 1 + 1;
|
61
|
|
- char path[len];
|
62
|
|
-
|
63
|
59
|
// Get the short name for the item, which we know is a folder
|
64
|
60
|
char lfilename[FILENAME_LENGTH];
|
65
|
61
|
createFilename(lfilename, p);
|
66
|
62
|
|
|
63
|
+ // Allocate enough stack space for the full path to a folder, trailing slash, and nul
|
|
64
|
+ boolean prepend_is_empty = (prepend[0] == '\0');
|
|
65
|
+ int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(lfilename) + 1 + 1;
|
|
66
|
+ char path[len];
|
|
67
|
+
|
67
|
68
|
// Append the FOLDERNAME12/ to the passed string.
|
68
|
69
|
// It contains the full path to the "parent" argument.
|
69
|
70
|
// We now have the full path to the item in this folder.
|
70
|
|
- path[0] = '\0';
|
71
|
|
- if (prepend[0] == '\0') strcat(path, "/"); // a root slash if prepend is empty
|
72
|
|
- strcat(path, prepend);
|
73
|
|
- strcat(path, lfilename);
|
74
|
|
- strcat(path, "/");
|
|
71
|
+ strcpy(path, prepend_is_empty ? "/" : prepend); // root slash if prepend is empty
|
|
72
|
+ strcat(path, lfilename); // FILENAME_LENGTH-1 characters maximum
|
|
73
|
+ strcat(path, "/"); // 1 character
|
75
|
74
|
|
76
|
75
|
// Serial.print(path);
|
77
|
76
|
|