discomfitor pushed a commit to branch master.

http://git.enlightenment.org/apps/empc.git/commit/?id=2b2e3baf0d7831dc0fb0f851dd13c71d5b163f40

commit 2b2e3baf0d7831dc0fb0f851dd13c71d5b163f40
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Mon Feb 8 11:52:46 2016 -0500

    improve apm directory matching algorithm with nested album directories
    
    should work better for cases involving albums with songs split across many
    subdirectories
---
 src/modules/auto_playlist_manager.c | 20 ++++++++++++++++++--
 1 file 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)
 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

-- 


Reply via email to