MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / checkFileExtension

Function checkFileExtension

lib/FsHelpers/FsHelpers.cpp:132–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132bool checkFileExtension(std::string_view fileName, const char* extension) {
133 const size_t extLen = strlen(extension);
134 if (fileName.length() < extLen) {
135 return false;
136 }
137
138 const size_t offset = fileName.length() - extLen;
139 for (size_t i = 0; i < extLen; i++) {
140 if (tolower(static_cast<unsigned char>(fileName[offset + i])) !=
141 tolower(static_cast<unsigned char>(extension[i]))) {
142 return false;
143 }
144 }
145 return true;
146}
147
148bool hasJpgExtension(std::string_view fileName) {
149 return checkFileExtension(fileName, ".jpg") || checkFileExtension(fileName, ".jpeg");

Callers 9

hasJpgExtensionFunction · 0.70
hasPngExtensionFunction · 0.70
hasBmpExtensionFunction · 0.70
hasGifExtensionFunction · 0.70
hasEpubExtensionFunction · 0.70
hasXtcExtensionFunction · 0.70
hasTxtExtensionFunction · 0.70
hasMarkdownExtensionFunction · 0.70
hasCssExtensionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected