static size_t iso_convert_name(char *dst, const char *src, int len) { char *p = dst; char c; if (len == 1) { switch (*src) { case 1: *p++ = '.'; /* fall through */ case 0: *p++ = '.'; goto done; default: /* nothing special */ break; } } while (len-- && (c = *src++)) { if (c == ';') /* Remove any filename version suffix */ break; *p++ = iso_tolower(c); } /* Then remove any terminal dots */ while (p > dst+1 && p[-1] == '.') p--; done: *p = '\0'; return p - dst; }
/* * Unlike strcmp, it does return 1 on match, or reutrn 0 if not match. */ static bool iso_compare_name(const char *de_name, size_t len, const char *file_name) { char iso_file_name[256]; char *p = iso_file_name; char c1, c2; size_t i; i = iso_convert_name(iso_file_name, de_name, len); dprintf("Compare: \"%s\" to \"%s\" (len %zu)\n", file_name, iso_file_name, i); do { c1 = *p++; c2 = iso_tolower(*file_name++); /* compare equal except for case? */ if (c1 != c2) return false; } while (c1); return true; }