- // Determine section id
- if (tmp == sec_lastfiles) {
- section = id_lastfiles;
- } else if (tmp == sec_lastfilepos) {
- section = id_lastfilepos;
- } else if (tmp == sec_lastopened) {
- section = id_lastopened;
- } else if (tmp == sec_bookmarks) {
- section = id_bookmarks;
- } else if (tmp == sec_session) {
- section = id_session;
- } else if (section == id_lastfiles) {
- // read lastfiles
- if (!fs::exists(tmp) || lastfiles.size() >= num_lastfiles)
- continue;
- lastfiles.push_back(tmp);
- } else if (section == id_lastfilepos) {
- // read lastfilepos
- // pos, file\n
- pit_type pit;
- pos_type pos;
- string fname;
- istringstream itmp(tmp);
- itmp >> pit;
- itmp.ignore(2); // ignore ", "
- itmp >> pos;
- itmp.ignore(2); // ignore ", "
- itmp >> fname;
- if (!fs::exists(fname) || lastfilepos.size() >= num_lastfilepos)
- continue;
- lastfilepos[fname] = boost::tie(pit, pos);
- } else if (section == id_lastopened) {
- // read lastopened
- // files
- if (!fs::exists(tmp))
- continue;
- lastopened.push_back(tmp);
- } else if (section == id_bookmarks) {
- // read bookmarks
- // bookmarkid, id, pos, file\n
- unsigned int num;
- unsigned int id;
- pos_type pos;
- string fname;
- istringstream itmp(tmp);
- itmp >> num;
- itmp.ignore(2); // ignore ", "
- itmp >> id;
- itmp.ignore(2); // ignore ", "
- itmp >> pos;
- itmp.ignore(2); // ignore ", "
- itmp >> fname;
- // only load valid bookmarks
- if (fs::exists(fname))
- bookmarks.push_back(boost::tie(num, fname, id, pos));
- } else if (section == id_session) {
- // Read session info, saved as key/value pairs
- // would better yell if pos returns npos
- string::size_type pos = tmp.find_first_of(" = ");
- string key = tmp.substr(0, pos);
- string value = tmp.substr(pos + 3);
- sessioninfo[key] = value;
- }
- }