void remove_user_subsession(const int session_uid, const std::string_view subsession_id)
{
try {
- std::string main_dir = get_main_dir_by_user_id(session_uid);
+ const auto subsession_path = fs::path(get_main_dir_by_user_id(session_uid)) / subsession_id;
- std::string subsession_dir = main_dir + "/" + subsession_id.data();
- const fs::path subsession_path { std::move(subsession_dir) };
if (!fs::exists(subsession_path))
throw std::system_error(ENOENT, std::generic_category(),
"Subsession directory does not exist");
* name is different than the one for adding a subsession to avoid
* a possible collision with `add_user_subsession` which also uses
* a temporary dir. */
- std::string tmp_subsession_dir = std::move(main_dir) + "/.tmpremove" + subsession_id.data();
- const fs::path tmp_subsession_path { std::move(tmp_subsession_dir) };
+ const auto tmp_subsession_path = fs::path(subsession_path)
+ .replace_filename(".tmpremove"s + subsession_path.filename().native());
/* Ensure that any possible residue from previously
* failed subsession deletion is cleaned up. */