Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 23168 - xmms not sorting files in directories
Summary: xmms not sorting files in directories
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Highest minor (vote)
Assignee: Gentoo Sound Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-20 07:13 UTC by Frederik Schmid
Modified: 2003-06-26 04:26 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch+ebuild (xmms-ebuild.tar.gz,9.67 KB, application/x-gzip)
2003-06-20 07:21 UTC, Frederik Schmid
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frederik Schmid 2003-06-20 07:13:20 UTC
I find it very annoying that xmms does not sort the files in directories 
according to filenames when added to the playlist.

A possible fix:
------------------------------ CUT HERE ----------------------------------------
diff -urN xmms-1.2.7/xmms/playlist.c xmms-1.2.7-p1/xmms/playlist.c
--- xmms-1.2.7/xmms/playlist.c	2003-06-19 19:49:47.000000000 +0200
+++ xmms-1.2.7-p1/xmms/playlist.c	2003-06-19 19:46:56.000000000 +0200
@@ -307,6 +307,17 @@
 		}
 }

+static gint sort_dir_cmpfunc(const char * a_filename, const char * b_filename)
+{
+	if (strchr(a_filename, '/'))
+		a_filename = strrchr(a_filename, '/') + 1;
+
+	if (strchr(b_filename,'/'))
+		b_filename = strrchr(b_filename, '/') + 1;
+
+	return strcasecmp(a_filename, b_filename);
+}
+
 static guint playlist_ins_dir_real(gchar * path, glong pos)
 {
 	DIR *dir;
@@ -314,7 +325,7 @@
 	struct stat statbuf;
 	gchar *temp;
 	guint entries = 0;
-	GList *list;
+	GList *list, *node;

 	if (path[strlen(path) - 1] != '/')
 		temp = g_strconcat(path, "/", NULL);
@@ -322,22 +333,7 @@
 		temp = g_strdup(path);

 	if ((list = input_scan_dir(temp)) != NULL)
-	{
-		GList *node;
-		g_free(temp);
-		node = list;
-		while (node)
-		{
-			__playlist_ins(node->data, pos);
-			entries++;
-			if (pos >= 0)
-				pos++;
-			g_free(node->data);
-			node = g_list_next(node);
-		}
-		g_list_free(list);
-		return entries;
-	}
+		goto add_files;
 
 	if ((dir = opendir(path)) == NULL)
 	{
@@ -354,8 +350,10 @@

 		filename = g_strconcat(temp, dirent->d_name, NULL);

-		if (stat(filename, &statbuf) < 0)
-			goto next;
+		if (stat(filename, &statbuf) < 0) {
+			g_free(filename);
+			continue;
+		}

 		if (S_ISDIR(statbuf.st_mode))
 		{
@@ -367,16 +365,25 @@
 		}
 		else if (input_check_file(filename))
 		{
-			__playlist_ins(filename, pos);
-			entries++;
-			if (pos >= 0)
-				pos++;
+			list = g_list_append(list, filename);
 		}
-	next:
-		g_free(filename);
 	}
 	closedir(dir);
+
+add_files:
 	g_free(temp);
+	list = g_list_sort(list, (GCompareFunc) sort_dir_cmpfunc);
+	node = list;
+	while (node)
+	{
+		__playlist_ins(node->data, pos);
+		entries++;
+		if (pos >= 0)
+			pos++;
+		g_free(node->data);
+		node = g_list_next(node);
+	}
+	g_list_free(list);

 	return entries;
 }
------------------------------ CUT HERE ----------------------------------------

I also have a complete package with patch/ebuild... but I don't know how to post 
that here.
Comment 1 Frederik Schmid 2003-06-20 07:21:27 UTC
Created attachment 13592 [details]
patch+ebuild

Enable PORTAGE_OVERLAY in /etc/make.conf
Extract the tarball to /usr/local/portage
cd /usr/local/portage/media-sound/xmms
ebuild xmms-1.2.7-r22 digest
emerge xmms-1.2.7-r22
Comment 2 Mr. Bones. (RETIRED) gentoo-dev 2003-06-20 11:37:36 UTC
Frederik - this is probably the kind of thing that needs to be sent upstream.
You should probably send this patch to the xmms maintainers if you haven't
done so already.
Comment 3 Frederik Schmid 2003-06-20 12:47:25 UTC
done
Comment 4 rob holland (RETIRED) gentoo-dev 2003-06-26 04:26:55 UTC
killing the ticket. it really does belong upstream.