return result;
}
+ int filterLen = nameFilter.size();
+
while (true) {
struct dirent* entry = readdir(dp);
if (!entry) {
}
if (!nameFilter.empty()) {
- if (strstr(entry->d_name, nameFilter.c_str()) == NULL) {
+ int nameLen = strlen(entry->d_name);
+ if (nameLen < filterLen) {
+ continue; // name is shorter than the filter
+ }
+
+ char* nameSuffix = entry->d_name + (nameLen - filterLen);
+ if (strcmp(nameSuffix, nameFilter.c_str())) {
continue;
}
}