fs::path Path::MakeAbsolute(fs::path path, std::string const& token) const { if (path.empty()) return path; int idx = find_token(token.c_str(), token.size()); if (idx == -1) throw agi::InternalError("Bad token: " + token); path.make_preferred(); const auto str = path.string(); if (boost::starts_with(str, "?dummy") || boost::starts_with(str, "dummy-audio:")) return path; return (paths[idx].empty() || path.is_absolute()) ? path : paths[idx]/path; }
void Path::SetToken(const char *token_name, fs::path const& token_value) { int idx = find_token(token_name, strlen(token_name)); if (idx == -1) throw agi::InternalError("Bad token: " + std::string(token_name)); if (token_value.empty()) paths[idx] = token_value; else if (!token_value.is_absolute()) paths[idx].clear(); else { paths[idx] = token_value; paths[idx].make_preferred(); if (fs::FileExists(paths[idx])) paths[idx] = paths[idx].parent_path(); } }