c++ open all files in directory

#include <iostream>
#include <fstream>
#include <filesystem>

namespace fs = std::filesystem;

int main() {
    const std::string directory_path = "/path/to/your/directory/";

    for (const auto& entry : fs::directory_iterator(directory_path)) {
        if (fs::is_regular_file(entry.path())) {
            std::ifstream file(entry.path());
            if (file.is_open()) {
                std::cout << "Contents of file " << entry.path() << ":\n";
                std::string line;
                while (std::getline(file, line)) {
                    std::cout << line << "\n";
                }
                std::cout << "------------------------\n";
                file.close();
            } else {
                std::cerr << "Error opening file " << entry.path() << "\n";
            }
        }
    }

    return 0;
}