Код
#include <iostream>
#include <algorithm>
#include <limits>
#include <boost/filesystem.hpp>
int main()
{
using namespace boost::filesystem ;
using rdi = boost::filesystem::recursive_directory_iterator ;
size_t min_file_size = std::numeric_limits<size_t>::max() ;
path min_size_path ;
std::for_each(
rdi("/home/sasha/cpp/test"),
rdi() ,
[&min_file_size, &min_size_path](const boost::filesystem::directory_entry & dir_iter)
{
if( is_regular_file(dir_iter.path()) ){
size_t fsize = file_size(dir_iter.path()) ;
if( fsize<min_file_size ){
min_file_size = fsize ;
min_size_path = dir_iter.path() ;
}
}
}
) ;
std::cout << "file: " << min_size_path << "\n\tsize: " << min_file_size <<std::endl ;
}