Good evening.
I ma working with an Sd card and I have folders and files following this tructure:
2015/12/21/21/09-11-59.TXT
2015/12/21/23/21-24-17.TXT
Here is my fonction to read the SD card
void printDirectory(File dir, int numTabs) {
if(numTabs == 0)
{
}
while(true)
{
File entry = dir.openNextFile();
if (! entry)
{
// no more files
SerialUSB.println(F("Break"));
break;
}
for (uint8_t i=0; i<numTabs; i++)
{
SerialUSB.print('\t');
}
SerialUSB.print(entry.name(),0);
//strncat(sd_path_file, entry.name(), strlen(entry.name()));
if (entry.isDirectory())
{
SerialUSB.println("/");
printDirectory(entry, numTabs+1);
}
else
{
// files have sizes, directories do not
SerialUSB.print("\t\t");
SerialUSB.println(entry.size(), DEC);
}
entry.close();
}
It's works fine and it printed my Sd structure.
It's fine, but it only display in a Serial Monitor and I can not exploit the the files.
I would like to save the path, or let say the folders, in a variable.
My goal it to work (reading the data) of the latest saved files.
As you can see, there is a variable 'numTabs'. That variable show the depth of the folders.
For exemple, if numTabs is egal to 0, we are in folder 2015
if numTabs is egal to 1, we are in folder 12
if numTabs is egal to 2, we are in folder 21 ou 23
Is there a way to save a char in an array?
For exemple
char myArray[numTabs][]
to have something like this
// How can I declare it?
myArray[0][] = "2015";
myArray[1][] = "12";
myArray[2][] = "21";
// or
myArray[2][] = "23";
I am a bit confused to be clear in my question but my idea is to use the value of 'numTabs' to easly save the folder name and use the content.
I would like to read the content of the newest files, but I need to know it path
How can I save the folder structure in different variable according to 'numTabs' value?
Thank for your help and happy christmas first of all!