summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2016-02-08 11:52:46 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-02-06 12:11:42 -0500
commit2b2e3baf0d7831dc0fb0f851dd13c71d5b163f40 (patch)
tree0318e949447ed3485dd5a97a2a5e7e08c16b7a30 /src
parent85fc2cb869b04c44514d1bfc2ca70881b39fe795 (diff)
improve apm directory matching algorithm with nested album directories
should work better for cases involving albums with songs split across many subdirectories
Diffstat (limited to 'src')
-rw-r--r--src/modules/auto_playlist_manager.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/modules/auto_playlist_manager.c b/src/modules/auto_playlist_manager.c
index 5be64e3..65732a8 100644
--- a/src/modules/auto_playlist_manager.c
+++ b/src/modules/auto_playlist_manager.c
@@ -80,6 +80,7 @@ sort_cb(const char *a, const char *b)
80static inline Eina_Bool 80static inline Eina_Bool
81is_same_path(const char *a, const char *ae, const char *b, const char *be) 81is_same_path(const char *a, const char *ae, const char *b, const char *be)
82{ 82{
83 const char *suba = NULL, *subb = NULL;
83 if (!ae) 84 if (!ae)
84 { 85 {
85 ae = strrchr(a, '/'); 86 ae = strrchr(a, '/');
@@ -90,8 +91,23 @@ is_same_path(const char *a, const char *ae, const char *b, const char *be)
90 be = strrchr(b, '/'); 91 be = strrchr(b, '/');
91 if (be) be++; 92 if (be) be++;
92 } 93 }
93 if (ae - a != be - b) return EINA_FALSE; 94 /* if full match on all directories, match */
94 return !memcmp(a, b, ae - a); 95 if ((ae - a == be - b) && (!memcmp(a, b, ae - a))) return EINA_TRUE;
96 if (ae)
97 suba = memrchr(a, '/', ae - a - 1);
98 if (be)
99 subb = memrchr(b, '/', be - b - 1);
100 /* try to match subsections of directories:
101 * Artist/Album/CD 1/song
102 * Artist/Album/CD 2/song2
103 * this is valid
104 */
105 if (suba && subb)
106 {
107 if (suba - a != subb - b) return EINA_FALSE;
108 return !memcmp(a, b, suba - a);
109 }
110 return EINA_FALSE;
95} 111}
96 112
97static void 113static void