Sync
This commit is contained in:
@@ -1736,5 +1736,11 @@ void PiPedalModel::SetSystemMidiBindings(std::vector<MidiBinding> &bindings)
|
||||
|
||||
std::vector<std::string> PiPedalModel::GetFileList(const PiPedalFileProperty&fileProperty)
|
||||
{
|
||||
return this->storage.GetFileList(fileProperty);
|
||||
try {
|
||||
return this->storage.GetFileList(fileProperty);
|
||||
} catch (const std::exception & e)
|
||||
{
|
||||
Lv2Log::warning("GetFileList() failed: (%s)", e.what());
|
||||
return std::vector<std::string>(); // don't disclose to users what the problem is.
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -104,10 +104,10 @@ PiPedalFileProperty::PiPedalFileProperty(PiPedalHost *pHost, const LilvNode *nod
|
||||
nullptr);
|
||||
if (directory)
|
||||
{
|
||||
this->directory_ = name.AsString();
|
||||
this->directory_ = directory.AsString();
|
||||
if (!IsDirectoryNameValid(this->directory_))
|
||||
{
|
||||
throw std::logic_error("Pipedal FileProperty::director must have only alpha-numeric characters.");
|
||||
throw std::logic_error("Pipedal FileProperty::directory must have only alpha-numeric characters.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -181,6 +181,7 @@ bool pipedal::IsAlphaNumeric(const std::string&value)
|
||||
|
||||
bool PiPedalFileProperty::IsDirectoryNameValid(const std::string&value)
|
||||
{
|
||||
if (value.length() == 0) return false;
|
||||
return IsAlphaNumeric(value);
|
||||
}
|
||||
|
||||
|
||||
+11
-6
@@ -1418,16 +1418,21 @@ std::vector<std::string> Storage::GetFileList(const PiPedalFileProperty&fileProp
|
||||
std::vector<std::string> result;
|
||||
std::filesystem::path audioFileDirectory = this->GetAudioFilesDirectory() / fileProperty.directory();
|
||||
|
||||
for (auto const&dir_entry: std::filesystem::directory_iterator(audioFileDirectory))
|
||||
{
|
||||
if (dir_entry.is_regular_file())
|
||||
try {
|
||||
for (auto const&dir_entry: std::filesystem::directory_iterator(audioFileDirectory))
|
||||
{
|
||||
auto &path = dir_entry.path();
|
||||
if (fileProperty.IsValidExtension(path.extension().string()))
|
||||
if (dir_entry.is_regular_file())
|
||||
{
|
||||
result.push_back(fileProperty.directory() / path.filename());
|
||||
auto &path = dir_entry.path();
|
||||
if (fileProperty.IsValidExtension(path.extension().string()))
|
||||
{
|
||||
result.push_back(fileProperty.directory() / path.filename());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(const std::exception&error)
|
||||
{
|
||||
throw std::logic_error("Directory not found: " + audioFileDirectory.string());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user