Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How C++ boost::filesystem detect if path is file or directory?

Tags:

c++

boost

In boost::filesystem library is there any way to determine if the path is directory or file?

My scenario is : I have some folders and files which i need full path of the all files and push it to vector, so i did this :

for ( boost::filesystem::recursive_directory_iterator end, dir(pathBase);
    dir != end; ++dir ) {
    if ( boost::filesystem::exists( dir->path() ) )
    {
        std::cout << dir->path() << "\n";  // full path
        filenames.push_back(dir->path().string());
    }
  }

The problem is the exists method check if directory or file exist and could not detect their type(file or directory).

So how can i get only files with boost library?

like image 616
frdf Avatar asked Oct 23 '25 02:10

frdf


1 Answers

This sounds like you need boost::filesystem::is_regular_file.

like image 125
Christian Hackl Avatar answered Oct 24 '25 18:10

Christian Hackl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!