Hello guys,
I want to make 2 folders in SD card, one inside the other and then write to a file whose name is the date we get from an RTC. I know I have to add the full path when using SD.open(). So far I can create/write to the file using sprintf() but I can't put it inside the 2 folders because sprintf() is limited to a max of 8 characters so I can't use it to make the full path and put it in SD.open(). The file creation is as follows:
m = rtc.getTime().mon; //month
d = rtc.getTime().date; //day
y = rtc.getTime().year; //year
sprintf(filename,"%d%c%d.txt",m,'-',d);
I would prefer to keep the file name the same. So now i want to create a path like this: /'logfiles'/y/filename and navigate to it with SD.open(). The 'y' is the year we get from RTC. Any ideas how i can achieve this?
I think the limitation was the size of the character array.
I looked into it and you are right. It's the SD library that supports filenames of max 8 characters (and up to 3 for extension). It only supports the 8.3 format. So if I add the path before the filename it shouldn't be an issue right? In the end the filename wont be more than 8 characters. I also have 1 more question. If the folders do not exist and I add the full path in SD.open() then will it also create the missing folders just like it happens with the files?
fikos:
I looked into it and you are right. It's the SD library that supports filenames of max 8 characters (and up to 3 for extension). It only supports the 8.3 format. So if I add the path before the filename it shouldn't be an issue right? In the end the filename wont be more than 8 characters. I also have 1 more question. If the folders do not exist and I add the full path in SD.open() then will it also create the missing folders just like it happens with the files?
Nevermind, I found the answer in the SD.open() description. The folders must already exist so you have to create them yourself. And the input to the function can be the whole path. Thanks anyway!