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
Jump to PostTraversing 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 …
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.
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........
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!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.