example/draw/draw.cpp
/**
 * Return all regular files in the specified directory with the given extension.
 * 
 * The names don't contain the directory path.
 * If no extension or an empty extension is given, returns all regular files.
 * 
 * @param path            the path to the directory
 * @param file_extension  the extension to search for
 * 
 * @return all files in the directory with the given extension
 */
Return all regular files in the specified directory with the given extension.

The names don't contain the directory path.
If no extension or an empty extension is given, returns all regular files.

@param path            the path to the directory
@param file_extension  the extension to search for

@return all files in the directory with the given extension
Return all regular files in the specified directory with the given extension . The names don ' t contain the directory path . If no extension or an empty extension is given returns all regular files . @param path the path to the directory @param file_extension the extension to search for @return all files in the directory with the given extension
std::vector<fs::path> dir_contents(const fs::path& dir_path, const std::string file_extension="") {
    std::vector<fs::path> contents;
    for (const auto& entry : std::filesystem::directory_iterator(dir_path)) {
        if (entry.is_regular_file()) {
            if (file_extension == "" || entry.path().extension() == file_extension) {
                contents.push_back( entry.path() );
            }
        }
    }
    return contents;
}
std :: vector < fs :: path > dir_contents ( const fs :: path & dir_path , const std :: string file_extension = " " ) { std :: vector < fs :: path > contents ; for ( const auto & entry : std :: filesystem :: directory_iterator ( dir_path ) ) { if ( entry . is_regular_file ( ) ) { if ( file_extension == " " || entry . path ( ) . extension ( ) == file_extension ) { contents . push_back ( entry . path ( ) ) ; } } } return contents ; }
Return all regular files in the specified directory with the given extension.
Return all regular files in the specified directory with the given extension .