mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Merge pull request #355 from tdaede/lowercase
Make filename endings case insensitive.
This commit is contained in:
@@ -58,12 +58,10 @@ void ImageReader::updateConfigForFilename(ImageReaderProto* proto, const std::st
|
|||||||
{".dim", [&]() { proto->mutable_dim(); }},
|
{".dim", [&]() { proto->mutable_dim(); }},
|
||||||
{".diskcopy", [&]() { proto->mutable_diskcopy(); }},
|
{".diskcopy", [&]() { proto->mutable_diskcopy(); }},
|
||||||
{".fdi", [&]() { proto->mutable_fdi(); }},
|
{".fdi", [&]() { proto->mutable_fdi(); }},
|
||||||
{".FDI", [&]() { proto->mutable_fdi(); }},
|
|
||||||
{".img", [&]() { proto->mutable_img(); }},
|
{".img", [&]() { proto->mutable_img(); }},
|
||||||
{".st", [&]() { proto->mutable_img(); }},
|
{".st", [&]() { proto->mutable_img(); }},
|
||||||
{".nsi", [&]() { proto->mutable_nsi(); }},
|
{".nsi", [&]() { proto->mutable_nsi(); }},
|
||||||
{".td0", [&]() { proto->mutable_td0(); }},
|
{".td0", [&]() { proto->mutable_td0(); }},
|
||||||
{".TD0", [&]() { proto->mutable_td0(); }},
|
|
||||||
{".xdf", [&]() { proto->mutable_img(); }},
|
{".xdf", [&]() { proto->mutable_img(); }},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,15 @@ bool beginsWith(const std::string& value, const std::string& ending)
|
|||||||
return std::equal(ending.begin(), ending.end(), value.begin());
|
return std::equal(ending.begin(), ending.end(), value.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Case-insensitive for endings within ASCII.
|
||||||
bool endsWith(const std::string& value, const std::string& ending)
|
bool endsWith(const std::string& value, const std::string& ending)
|
||||||
{
|
{
|
||||||
if (ending.size() > value.size())
|
if (ending.size() > value.size())
|
||||||
return false;
|
return false;
|
||||||
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
|
std::string lowercase(ending.size(), 0);
|
||||||
|
std::transform(value.rbegin(), value.rbegin() + ending.size(), lowercase.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||||
|
return std::equal(ending.rbegin(), ending.rend(), value.rbegin()) ||
|
||||||
|
std::equal(ending.rbegin(), ending.rend(), lowercase.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user