Following is a code snippet I used to get directory size in c++:
boost::system::error_code ec;
boost::filesystem::space_info si =
boost::filesystem::space(path, ec);
if (ec.value() == 0) {
cout << si.capacity - si.available;
}
But the above snippet seems to be giving the entire disk size instead of a particular directory size on a disk since I passed 2 different directory paths to above but both of them gave the same answer. Can someone help me with finding what's wrong with this or give me another alternative for getting the directory size in c++? TIA!