Facebook
From Silly Kitten, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 242
  1. bool name_contains(dirent const &entry, std::string const &match, bool const at_end)
  2. 214 {
  3. 215     auto const len_fname = strnlen(entry.d_name, sizeof_array(entry.d_name));
  4. 216     auto const len_match = match.length();
  5. 217
  6. 218     if (len_match > len_fname) {
  7. 219         return false;
  8. 220     }
  9. 221
  10. 222     auto const offset = at_end ? (len_fname - len_match) : 0;
  11. 223     return strstr(entry.d_name + offset, match.c_str()) != 0;
  12. 224 }
  13. 225
  14.