I have a loop that run through the whole directory I need to get a path from each file in order to use it.
This is my method
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
for (const auto & entry : fs::directory_iterator(sourceDir))
{
    if (fs::is_directory(entry))
        continue;
    StreamRAII iStream{ entry, StreamMode::READ_BINARY };
}
issue is that StreamRAII constructor have to get std::string as its first parameter
StreamRAII(const std::string& filename, const char *mode);
But this const auto & entry : fs::directory_iterator(sourceDir), entry is derectory_entry type. 
Question is,  how to get path to my file? How to convert derectory_entry to std::string or char[]?
P.S. when I use cout I can see this path to my files... 
derectory_entry has a path() function that returns a std::filesystem::path that holds the path name of the file.  You can use it's string() function to get a std::string from that path.  That would make your code look like
StreamRAII iStream{ entry.path().string(), StreamMode::READ_BINARY };
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With