Question

So, I'm trying to change my directory to save files, and then change back to the directory I was previously in.

Essentially:

cd folder_name
<save file>
cd ../

Here is the code I have so far:

void save_to_folder(struct fann * network, const char * save_name)
{
    boost::filesystem::path config_folder(Config::CONFIG_FOLDER_NAME);
    boost::filesystem::path parent_folder("../");


    if( !(boost::filesystem::equivalent(config_folder, boost::filesystem::current_path())))
        {
            if( !(boost::filesystem::exists(config_folder)))
            {
                std::cout << "Network Config Directory not found...\n";
                std::cout << "Creating folder called " << Config::CONFIG_FOLDER_NAME << "\n";
                boost::filesystem::create_directory(config_folder);
            }
            boost::filesystem::current_path(config_folder);
        }

    fann_save(network, save_name);
    boost::filesystem::current_path(parent_folder);

}

Currently, what is happening is this every time the method is called:
Folder doesn't exist: gets created
Folder doesn't exist: gets created

It's not doing the cd ../ part. =(

so my directory structure looks like this:

folder_name
- folder_name
-- folder_name
--- folder_name

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top