dimanche 20 mai 2018

boost::filesystem::create_directory threw a boost::filesystem::filesystem_error: Bad address

The TL;DR of my code is the following:

server::server(boost::filesystem::path mappath) : mappath(mappath) {
    if(boost::filesystem::is_directory(mappath) && boost::filesystem::exists(mappath)) {
        // Do some stuff here
    } else {
        boost::filesystem::create_directory(mappath);
    }
}

The code works when mappath exists (barely, as I find Boost to be segfaulting in almost every function).
However, when it doesn't, it throws an exception with the message "Bad address".
When I print mappath via std::cout, it returns:

"/home/myusername/.testfolder/huni/ENTER YOUR TEXT HERE"

Which is correct.

Note that, when I try printing mappath inside the else statement, it segfaults.
I've deduced that something messes with mappath in either is_directory or exists, as there were no errors when printing before the if statement.

Aucun commentaire:

Enregistrer un commentaire