2023-01-12 08:32 PM
2023-01-13 04:11 AM
FAT FS has not information about folder data volume. Implicit folder size is number of bytes occupied by folder directory structure (min. one cluster). So, only way is sum all files in foldes and subfolders (as AScha.3 mentioned).
For quick info, you should scan whole file structure when device is connected and create some database in memory or as the file in the medium.
2023-01-13 02:12 AM
Hello @MDevi.1
you can use the f_stat() function from the ff.h file present in the original source package.
This function will return the size of the folder in bytes. Alternatively, you can also use the f_getfree() function, which will return the number of free clusters on the drive, which can be used to calculate the size of the folder.
Hope that helps!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-01-13 02:30 AM
Thank you for your reply, I used these functions, f_stat() is only returning size of file, not the size of folder, and f_getfree() returns overall free space. But my requirement is to find the size of directory/folder and sub-folder. I need to find each sub-folder size individually.
2023-01-13 03:19 AM
so you have to scan the folder you want to know: size of all files added together = your wanted "folder size" ; if subdirect. are there, is up to you , to get size of this folder alone or including subs, then you have to recursively scan subs and subsubs...and sum.
2023-01-13 03:39 AM
Actually my task is audio recording application, there will be lot files, if i keep on reading them, it consume lot of time. I need to check size of folder before recording, if it crosses the limit, then i have to delete old folders. If i go for keep on reading the all available files and adding their size, checking after that means time taking, so there is a high chance of data loss.
2023-01-13 04:11 AM
FAT FS has not information about folder data volume. Implicit folder size is number of bytes occupied by folder directory structure (min. one cluster). So, only way is sum all files in foldes and subfolders (as AScha.3 mentioned).
For quick info, you should scan whole file structure when device is connected and create some database in memory or as the file in the medium.
2023-01-14 06:45 PM
You keep asking questions about basically the same issue, but you do not provide details, do not participate in discussion and do not listen to what others are saying.
> there will be lot files, if i keep on reading them, it consume lot of time
Then you need to think and come up with a better solution.
2023-01-16 10:50 PM
Thank you for your responses.