How can i find the size of a file that is found using a directory iterator?

What i mean is i need to parse through a folder on my computer using 'directory_iterator d(folder);' and i know that to gain access to the file the d is pointing to i need to do this: path p = d->path(); (at least i think i need to do that) but anyways once i have p as the file that it is pointing to, how do i access the information of that file, for example i want to figure out what file extension the file has and what size it is in Bytes. Thanks in advance for your help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <boost/filesystem.hpp>

int main()
{
    boost::filesystem::path p = __FILE__ ;

    std::cout << "path: " << p
              << "\n    root name: " << p.root_name()
              << "\n    root directory: " << p.root_directory()
              << "\n    root path: " << p.root_path()
              << "\n    filename: " << p.filename()
              << "\n    stem: " << p.stem()
              << "\n    extension: " << p.extension() << '\n';

    if( is_regular_file(p) )
        std::cout << "    size: " << boost::filesystem::file_size(p) << '\n' ;
}
Topic archived. No new replies allowed.