ealeon
ealeon

Reputation: 12452

c++ looping through files in a directory

I am not sure if this is possible but is it possible to loop through files in a directory in c++?

For example, how do I know how many files there are in a directory from c++ file and how do I individually call that file instead of manually giving the path to each file which would be extremely painful?

while(1){
   pcl::io::loadPCDFile<pcl::PointXYZ> ("getFiles.pcd", *cloud1); <-- each file
}

Upvotes: 2

Views: 4288

Answers (1)

Ben Voigt
Ben Voigt

Reputation: 283684

There are OS-specific solutions, like

  • opendir and readdir on Linux
  • FindFirstFile and FindNextFile on Windows

or you can use Boost Filesystem, which has already figured out all the OS-specific bits.

Upvotes: 3

Related Questions