0

Hi,

How to get directory size?
Recursive alogrithm take more time for calculating directory size.
so I don't like search a recursive algorithm.
Any other method

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Salem
0

What do you mean? Find the number of files in a directory? Find the total size of files in a directory?

I don't like search a recursive algorithm.

It would be the algorithm I would choose anyways.

0

What do you mean? Find the number of files in a directory? Find the total size of files in a directory?


I called this function recursively for calculate the directory size.

struct stat filedetails = this->GetFileStat(fileName);
filesize = myStat.st_size;

It wil take more time.
I am trying another method.
Anybody any ideas........

0

Traversing the subdirectory tree is the only way, if that is what you're after.

Think about how file systems are implemented?
If you have /path/to/some/directory, does it make sense to update /path/to/some, /path/to, /path and finally / every time you add/delete/change a file in some sub-directory?

Sure, it gives you a nice easy answer, and the other 99% of the time you're cursing this horribly slow file system!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.