@@ -3,6 +3,7 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <system_error>
|
||||
@@ -96,6 +97,27 @@ auto vamp_zero::score_paths(std::string const &assets_path, vamp_zero::score_cat
|
||||
return std::unexpected(vamp_zero::make_error(vamp_zero::error_code::UNAVAILABLE, "failed to scan score assets: " + error.message()));
|
||||
}
|
||||
std::sort(paths.begin(), paths.end());
|
||||
if (practice) {
|
||||
auto exercises = std::map<std::string, std::filesystem::path>{};
|
||||
auto variants = std::map<std::string, std::filesystem::path>{};
|
||||
for (auto const &path : paths) {
|
||||
auto relative = path.lexically_relative(root);
|
||||
auto exercise_path = relative.parent_path();
|
||||
auto id = std::string{};
|
||||
for (auto const &part : exercise_path) {
|
||||
id += (id.empty() ? "" : "-") + part.string();
|
||||
}
|
||||
auto [exercise, added] = exercises.emplace(id, relative);
|
||||
if (!added && exercise->second.parent_path() != exercise_path) {
|
||||
return std::unexpected(invalid("practice exercise ID collision '" + id + "': " + (root / exercise->second).string() + " and " + path.string()));
|
||||
}
|
||||
auto variant_id = id + "-" + path.stem().string();
|
||||
auto [variant, unique] = variants.emplace(variant_id, relative);
|
||||
if (!unique) {
|
||||
return std::unexpected(invalid("practice variant ID collision '" + variant_id + "': " + (root / variant->second).string() + " and " + path.string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user