Core/ResourceLoader: Use stream path extension if possible to dismiss loaders
This commit is contained in:
parent
aa441354ec
commit
35c498bf21
|
|
@ -199,6 +199,9 @@ namespace Nz
|
||||||
NazaraAssert(stream.GetCursorPos() < stream.GetSize(), "No data to load");
|
NazaraAssert(stream.GetCursorPos() < stream.GetSize(), "No data to load");
|
||||||
NazaraAssert(parameters.IsValid(), "Invalid parameters");
|
NazaraAssert(parameters.IsValid(), "Invalid parameters");
|
||||||
|
|
||||||
|
// Retrieve extension from stream (if any)
|
||||||
|
std::string ext = ToLower(PathToString(stream.GetPath().extension()));
|
||||||
|
|
||||||
UInt64 streamPos = stream.GetCursorPos();
|
UInt64 streamPos = stream.GetCursorPos();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (auto& loaderPtr : m_loaders)
|
for (auto& loaderPtr : m_loaders)
|
||||||
|
|
@ -208,6 +211,9 @@ namespace Nz
|
||||||
if (loader.parameterFilter && !loader.parameterFilter(parameters))
|
if (loader.parameterFilter && !loader.parameterFilter(parameters))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (loader.extensionSupport && !ext.empty() && !loader.extensionSupport(ext))
|
||||||
|
continue;
|
||||||
|
|
||||||
stream.SetCursorPos(streamPos);
|
stream.SetCursorPos(streamPos);
|
||||||
|
|
||||||
// Load resource
|
// Load resource
|
||||||
|
|
@ -216,9 +222,10 @@ namespace Nz
|
||||||
{
|
{
|
||||||
ResourceLoadingError error = result.GetError();
|
ResourceLoadingError error = result.GetError();
|
||||||
if (error != ResourceLoadingError::Unrecognized)
|
if (error != ResourceLoadingError::Unrecognized)
|
||||||
|
{
|
||||||
NazaraError("failed to load resource: loader failed");
|
NazaraError("failed to load resource: loader failed");
|
||||||
else
|
|
||||||
found = true;
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue