Catch directory access exceptions in Playlist class.

No error handling or feedback mechanism yet.
This commit is contained in:
Kai Blaschke
2022-12-04 21:53:36 +01:00
parent 381fe4f51e
commit 830dc74ff0

View File

@ -86,21 +86,29 @@ auto Playlist::AddPath(const std::string& path, uint32_t index, bool recursive,
m_presetHistory.clear();
if (recursive)
{
for (const auto& entry : recursive_directory_iterator(path))
try
{
if (is_regular_file(entry) && entry.path().extension() == ".milk")
for (const auto& entry : recursive_directory_iterator(path))
{
uint32_t currentIndex{InsertAtEnd};
if (index < InsertAtEnd)
if (is_regular_file(entry) && entry.path().extension() == ".milk")
{
currentIndex = index + presetsAdded;
}
if (AddItem(entry.path().string(), currentIndex, allowDuplicates))
{
presetsAdded++;
uint32_t currentIndex{InsertAtEnd};
if (index < InsertAtEnd)
{
currentIndex = index + presetsAdded;
}
if (AddItem(entry.path().string(), currentIndex, allowDuplicates))
{
presetsAdded++;
}
}
}
}
catch (std::exception&)
{
// Todo: Add failure feedback
return presetsAdded;
}
}
else
{