void savePersistentData(const PersistentData &data, const string& filename) { try { getPersistentProps(); // Try opening the file ofstream ofs (filename.c_str(), ios_base::binary | ios_base::out | ios_base::trunc); if (ofs.is_open()) { // SERIALIZE_BINARY boost::archive::binary_oarchive oa(ofs); oa << data; // Close file and sync ofs.close(); os_abstract::sync(); } else { format msg("could not open file [%s]"); msg % filename; throw EGeneric(msg.str()); } } catch(std::exception &e){ LOG_S20(getPath(),e.what()) } // Emit event. m_persistentDataSavedEvent.emit(m_filePathData); } void loadPersistentData(PersistentData &data, const string& filename) { ifstream ifs; ifstream ifs2; try { os_abstract::sync(); try { // Try opening the file ifs.open (filename.c_str(), ios_base::binary | ios_base::in); if (ifs.fail()){ LOG_S21(filename,"Failed opening file.") } if (!ifs.good()){ LOG_S21(filename,"File not good.") } if (ifs.is_open()) { // SERIALIZE_BINARY boost::archive::binary_iarchive ia(ifs); ia >> data; // Close file and sync ifs.close(); } } catch(std::exception &e){ // Close file and sync ifs.close(); LOG_S21(filename,e.what()) } os_abstract::sync(); setPersistentProps(); } catch(std::exception &e){ LOG_S21(filename,e.what()) } }