Directory size (via boost::filesystem) problem
Okay so i just wrote this quick program to test boost::filesystem's
features out. It's supposed to find the size of a directory (the sum of
the size of the files in it) and optionally recurse all subdirectories:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include
Daniel Wyatt wrote:
Its not too pretty but ignore that please. It works for the most part. It gives perfect results for nearly all directories. One exception i've noticed on my system is "C:\Program Files". It gives me "419.15 MiB" but it should be giving me something more like "8.40 GiB". I figure an unsigned long is large enough, isn't it?
No, unsigned long is just 32 bits, it is not enough.
Do i need to use an unsigned long long or is there something else wrong here???
Yes, you should use a 64 bit integer. PS: Boost.Filesystem has a recursive_directory_iterator, it is very good for such directory iteration job. cg
Okay so it actually was that the unsigned long's maximum was reached. I didn't actually think about that until the last second. Unsigned long long is plenty though.
participants (3)
-
Daniel Wyatt
-
Daniel Wyatt
-
gchen