improve apm directory matching algorithm with nested album directories

should work better for cases involving albums with songs split across many
subdirectories
This commit is contained in:
Mike Blumenkrantz 2016-02-08 11:52:46 -05:00
parent 85fc2cb869
commit 2b2e3baf0d
1 changed files with 18 additions and 2 deletions

View File

@ -80,6 +80,7 @@ sort_cb(const char *a, const char *b)
static inline Eina_Bool
is_same_path(const char *a, const char *ae, const char *b, const char *be)
{
const char *suba = NULL, *subb = NULL;
if (!ae)
{
ae = strrchr(a, '/');
@ -90,8 +91,23 @@ is_same_path(const char *a, const char *ae, const char *b, const char *be)
be = strrchr(b, '/');
if (be) be++;
}
if (ae - a != be - b) return EINA_FALSE;
return !memcmp(a, b, ae - a);
/* if full match on all directories, match */
if ((ae - a == be - b) && (!memcmp(a, b, ae - a))) return EINA_TRUE;
if (ae)
suba = memrchr(a, '/', ae - a - 1);
if (be)
subb = memrchr(b, '/', be - b - 1);
/* try to match subsections of directories:
* Artist/Album/CD 1/song
* Artist/Album/CD 2/song2
* this is valid
*/
if (suba && subb)
{
if (suba - a != subb - b) return EINA_FALSE;
return !memcmp(a, b, suba - a);
}
return EINA_FALSE;
}
static void