Add missing SImpleExtensionCheck

pull/4342/head
Kim Kulling 2022-01-19 21:42:14 +01:00
parent 4cb76e6a18
commit 17d5633a5b
3 changed files with 41 additions and 6 deletions

View File

@ -1521,12 +1521,6 @@ static unsigned int countEmbeddedTextures(glTF2::Asset &r) {
void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) { void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
mEmbeddedTexIdxs.resize(r.images.Size(), -1); mEmbeddedTexIdxs.resize(r.images.Size(), -1);
const unsigned int numEmbeddedTexs = countEmbeddedTextures(r); const unsigned int numEmbeddedTexs = countEmbeddedTextures(r);
/* for (size_t i = 0; i < r.images.Size(); ++i) {
if (r.images[i].HasData()) {
numEmbeddedTexs += 1;
}
}*/
if (numEmbeddedTexs == 0) { if (numEmbeddedTexs == 0) {
return; return;
} }

View File

@ -225,6 +225,32 @@ void BaseImporter::GetExtensionList(std::set<std::string> &extensions) {
return false; return false;
} }
// ------------------------------------------------------------------------------------------------
// Simple check for file extension
/*static*/ bool BaseImporter::SimpleExtensionCheck(const std::string &pFile,
const char *ext0,
const char *ext1,
const char *ext2) {
std::string::size_type pos = pFile.find_last_of('.');
// no file extension - can't read
if (pos == std::string::npos)
return false;
const char *ext_real = &pFile[pos + 1];
if (!ASSIMP_stricmp(ext_real, ext0))
return true;
// check for other, optional, file extensions
if (ext1 && !ASSIMP_stricmp(ext_real, ext1))
return true;
if (ext2 && !ASSIMP_stricmp(ext_real, ext2))
return true;
return false;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Get file extension from path // Get file extension from path
std::string BaseImporter::GetExtension(const std::string &file) { std::string BaseImporter::GetExtension(const std::string &file) {
@ -242,6 +268,7 @@ std::string BaseImporter::GetExtension(const std::string &file) {
return ret; return ret;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Check for magic bytes at the beginning of the file. // Check for magic bytes at the beginning of the file.
/* static */ bool BaseImporter::CheckMagicToken(IOSystem *pIOHandler, const std::string &pFile, /* static */ bool BaseImporter::CheckMagicToken(IOSystem *pIOHandler, const std::string &pFile,

View File

@ -260,6 +260,20 @@ public: // static utilities
bool tokensSol = false, bool tokensSol = false,
bool noAlphaBeforeTokens = false); bool noAlphaBeforeTokens = false);
// -------------------------------------------------------------------
/** @brief Check whether a file has a specific file extension
* @param pFile Input file
* @param ext0 Extension to check for. Lowercase characters only, no dot!
* @param ext1 Optional second extension
* @param ext2 Optional third extension
* @note Case-insensitive
*/
static bool SimpleExtensionCheck(
const std::string &pFile,
const char *ext0,
const char *ext1 = nullptr,
const char *ext2 = nullptr);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** @brief Extract file extension from a string /** @brief Extract file extension from a string
* @param pFile Input file * @param pFile Input file