cancel
Showing results for 
Search instead for 
Did you mean: 

FATFS Directory Size

jdcowpland
Associate II
Posted on May 07, 2014 at 15:08

Does anyone know if there's a command to get the size of a directory in Chan's FATFS or will I need to go the directory and just tally up all the file sizes?

3 REPLIES 3
chen
Associate II
Posted on May 07, 2014 at 15:22

''Does anyone know if there's a command to get the size of a directory in Chan's FATFS''

The question does not make sense.

A 'Directory' is just a special file. It happens to list (and link) a number of other files (and directories).

''will I need to go the directory and just tally up all the file sizes?''

If you want to know the total number of byte of all the files in a directory - Yes.

francescatodiego
Associate II
Posted on May 07, 2014 at 16:25

do you mean the

total size of files

in

a directory?

In

this case you can

use the code

http://elm-chan.org/fsw/ff/en/readdir.html

and sum all the files size

but I'm not

an expert on

FATFS

i don't 

know if there's

a faster way

Posted on May 07, 2014 at 17:49

Well there are probably other methods to determine the ''size'' of the directory itself, but for files within the subdirectory, and those in subdirectories below, would need to be enumerated through them. Remember the files might have a 2GB limit, but as you accumulate you'll need to use a 64-bit variable for the total.

There can be empty entries, and long file names which take up multiple entries depending on the name length.

FatFs is designed to be lightweight, you add features you need on top instead of having a bloated library for everyone.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..