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:
parent
85fc2cb869
commit
2b2e3baf0d
|
@ -80,6 +80,7 @@ sort_cb(const char *a, const char *b)
|
||||||
static inline Eina_Bool
|
static inline Eina_Bool
|
||||||
is_same_path(const char *a, const char *ae, const char *b, const char *be)
|
is_same_path(const char *a, const char *ae, const char *b, const char *be)
|
||||||
{
|
{
|
||||||
|
const char *suba = NULL, *subb = NULL;
|
||||||
if (!ae)
|
if (!ae)
|
||||||
{
|
{
|
||||||
ae = strrchr(a, '/');
|
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, '/');
|
be = strrchr(b, '/');
|
||||||
if (be) be++;
|
if (be) be++;
|
||||||
}
|
}
|
||||||
if (ae - a != be - b) return EINA_FALSE;
|
/* if full match on all directories, match */
|
||||||
return !memcmp(a, b, ae - a);
|
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
|
static void
|
||||||
|
|
Loading…
Reference in New Issue