Skip to main content
jdcowpland
Associate III
May 7, 2014
Question

FATFS Directory Size

  • May 7, 2014
  • 3 replies
  • 1001 views
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?

    This topic has been closed for replies.

    3 replies

    chen
    Associate II
    May 7, 2014
    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 III
    May 7, 2014
    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

    Tesla DeLorean
    Guru
    May 7, 2014
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..