Dash
Dash

Reputation: 308

Boost's read_ini throws exception "'=' character not found in line" but file structure is correct

I have the following throwing an exception that is logged as:

Failed to read in "Configuration File.ini". Exception: Configuration File.ini(1): '=' character not found in line

However, the structure of the file is correct.

The code:

ptree pt;
try {
    boost::property_tree::read_ini(workingDirectory, pt);
}
catch (const boost::property_tree::ptree_error &pe) {
    BOOST_LOG_SEV(cLogger, fatal) << "Failed to read in \"" << workingDirectory << "\". Exception: " << pe.what();
    return false;
}
catch (std::exception &ex) {
    BOOST_LOG_SEV(cLogger, fatal) << "Failed to read in \"" << workingDirectory << "\". Exception: " << ex.what();
    return false;
}

The curious thing is that the ini file is generated/modified by a different application and after the change does the exception get thrown. Yet, if I copy the exact contents of the ini file to a new file and rename it to "Configuration File.ini," there are no problems.

To specify, the other application closes the stream to the file upon completion, and even if the other application is not running, once the file has been modified by the other application at any point in time (i.e. even after reboot), this exception gets thrown.

Here are some of the things attempted and observations:

Thus, I am drawing the conclusion that it has something to do with the fact that "bad" files are those that have previously been edited/created by a different application, and no matter the content of the file itself, the same exception gets thrown. But, I cannot understand why.

Any thoughts/ideas?

Upvotes: 0

Views: 181

Answers (0)

Related Questions