I am using an SD card to log data. I need to check check how much free space there is. I know I can use LS_SIZE on the volume to list all the files and their respective sizes. My question is, how would I grab each of the individual file sizes so I can sum them. When listing all the files and sizes, the result looks like this:
And so on. Obviously file name on the left and size on the right.
That makes sense. How would you read in each file name? One catch I have is that the files will be generated and named as a time stamp. So in effect, I won’t know the file name up front to program in. If using something like LS, can I somehow read each of the file names in as a variable that I can then run entry.size() upon?
I cannot for the life of me figure out why doing so breaks my code. I have tried to keep as much of the listfiles example code the same as possible just for initial debugging purposes. If I take the "printDirectory" function out of my code and run it separately, it works as it should. Additionally, with it out of my code, the rest of my code works as it should. When I put it back in my code, the function does not print anything. Then, the rest of my code keeps telling me it can't open the current file created by the program.
not sure you're still interested in available SD memory, but when considering storage devices like an SD, you need to consider the number of blocks that are used. if a file contained just one byte, it still requires a block.
Last step of this project, I need to have a sort of initial file that is stored on the SD card that reads some initial parameters. Basically, when I plug in the SD card, I will have already saved a .txt file to it with a different integer on each line. I would like to read each integer into a different variable. Does anyone have a suggestion where to start? I'm chasing my tail on this one a bit.