void file_storage::update_path_index(internal_file_entry& e) { std::string parent = parent_path(e.filename()); if (parent.empty()) { e.path_index = -1; } else { // do we already have this path in the path list? std::vector<std::string>::reverse_iterator p = std::find(m_paths.rbegin(), m_paths.rend(), parent); if (p == m_paths.rend()) { // no, we don't. add it e.path_index = m_paths.size(); m_paths.push_back(parent); } else { // yes we do. use it e.path_index = p.base() - m_paths.begin() - 1; } e.set_name(filename(e.filename()).c_str()); } }