mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
ObjLoading: Display error message on directory_iterator throwing an exception
This commit is contained in:
parent
10342a7b58
commit
b8c2557482
@ -25,28 +25,36 @@ FileAPI::IFile* SearchPathFilesystem::Open(const std::string& fileName)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchPathFilesystem::Find(const SearchPathSearchOptions& options, const std::function<void(const std::string&)>& callback)
|
void SearchPathFilesystem::Find(const SearchPathSearchOptions& options,
|
||||||
|
const std::function<void(const std::string&)>& callback)
|
||||||
{
|
{
|
||||||
if (options.m_should_include_subdirectories)
|
try
|
||||||
{
|
{
|
||||||
std::filesystem::recursive_directory_iterator iterator(m_path);
|
if (options.m_should_include_subdirectories)
|
||||||
for (const auto entry = begin(iterator); iterator != end(iterator); ++iterator)
|
|
||||||
{
|
{
|
||||||
auto path = entry->path();
|
std::filesystem::recursive_directory_iterator iterator(m_path);
|
||||||
if (options.m_filter_extensions && path.extension().string() != options.m_extension)
|
for (const auto entry = begin(iterator); iterator != end(iterator); ++iterator)
|
||||||
continue;
|
{
|
||||||
callback(options.m_absolute_paths ? absolute(path).string() : path.string());
|
auto path = entry->path();
|
||||||
|
if (options.m_filter_extensions && path.extension().string() != options.m_extension)
|
||||||
|
continue;
|
||||||
|
callback(options.m_absolute_paths ? absolute(path).string() : path.string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::filesystem::directory_iterator iterator(m_path);
|
||||||
|
for (const auto entry = begin(iterator); iterator != end(iterator); ++iterator)
|
||||||
|
{
|
||||||
|
auto path = entry->path();
|
||||||
|
if (options.m_filter_extensions && path.extension().string() != options.m_extension)
|
||||||
|
continue;
|
||||||
|
callback(options.m_absolute_paths ? absolute(path).string() : path.string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (std::filesystem::filesystem_error& e)
|
||||||
{
|
{
|
||||||
std::filesystem::directory_iterator iterator(m_path);
|
printf("Directory Iterator threw error when trying to find files: \"%s\"\n", e.what());
|
||||||
for (const auto entry = begin(iterator); iterator != end(iterator); ++iterator)
|
|
||||||
{
|
|
||||||
auto path = entry->path();
|
|
||||||
if (options.m_filter_extensions && path.extension().string() != options.m_extension)
|
|
||||||
continue;
|
|
||||||
callback(options.m_absolute_paths ? absolute(path).string() : path.string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user