Ensure that default paths don't have duplicates
This commit is contained in:
parent
99b7780ff3
commit
21ed20bce1
1 changed files with 7 additions and 2 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
#include "SfizzForeignPaths.h"
|
#include "SfizzForeignPaths.h"
|
||||||
#include "NativeHelpers.h"
|
#include "NativeHelpers.h"
|
||||||
#include <absl/strings/ascii.h>
|
#include <absl/strings/ascii.h>
|
||||||
|
#include <absl/algorithm/container.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
@ -182,14 +183,18 @@ absl::Span<const fs::path> sfzDefaultPaths()
|
||||||
static const auto paths = []() -> std::vector<fs::path> {
|
static const auto paths = []() -> std::vector<fs::path> {
|
||||||
std::vector<fs::path> paths;
|
std::vector<fs::path> paths;
|
||||||
paths.reserve(8);
|
paths.reserve(8);
|
||||||
|
auto addPath = [&paths](const fs::path& newPath) {
|
||||||
|
if (absl::c_find(paths, newPath) == paths.end())
|
||||||
|
paths.push_back(newPath);
|
||||||
|
};
|
||||||
|
|
||||||
paths.push_back(getUserDocumentsDirectory() / "SFZ instruments");
|
addPath(getUserDocumentsDirectory() / "SFZ instruments");
|
||||||
|
|
||||||
for (const fs::path& foreign : {
|
for (const fs::path& foreign : {
|
||||||
getAriaPathSetting("user_files_dir"),
|
getAriaPathSetting("user_files_dir"),
|
||||||
getAriaPathSetting("Converted_path") })
|
getAriaPathSetting("Converted_path") })
|
||||||
if (!foreign.empty() && foreign.is_absolute())
|
if (!foreign.empty() && foreign.is_absolute())
|
||||||
paths.push_back(foreign);
|
addPath(foreign);
|
||||||
|
|
||||||
paths.shrink_to_fit();
|
paths.shrink_to_fit();
|
||||||
return paths;
|
return paths;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue