Hi,

Here is a patch I just made which add a .mpdrootignore on root directory.
How does it works ? This file a like a .mpdignore but only on music root 
directory. This file is parsed and used only if a .mpdignore file is not found 
(it's a fallback .mpdignore) which is apply to each subdirectory.

This is usefull when you want to ignore a file type recursively, like .mkv file
If you put *.mkv on .mpdrootignore, all .mkv files will be ignored
If a .mpdignore is found somewhere, the .mpdrootignore is ignored for that 
folder (you can make exceptions with this).

That's my first patch for mpd, be indigent :)
Thanks !

--
2c3fd8e2cca4044aead856108f1dd286  
0001-add-.mpdrootignore-fallback-giving-recursive-ignore.patch

-- 
Daniel Maxime
Linux version 3.10.9-maxux64 (syna) (gcc version 4.7.3 (Gentoo 4.7.3 p1.2, 
pie-0.5.5) ) #6 SMP Thu Sep 5 20:17:50 CEST 2013
 23:07:04 up 13 days,  3:44,  6 users,  load average: 0.19, 0.21, 0.33
>From dff6b7ba77fa0f2c7ccad77c790caaf7e5a81c3a Mon Sep 17 00:00:00 2001
From: Daniel Maxime <[email protected]>
Date: Thu, 17 Apr 2014 23:01:38 +0200
Subject: [PATCH 1/1] add .mpdrootignore fallback giving recursive ignore

Add a .mpdrootignore parser on root music directory. This file is used
only if a .mpdignore is not found.

If, for exemple, this file contains *.mkv, all mkv file will be ignored
recursively. If you want to keep *.mkv files from a sub directory, just
touch .mpdignore which will canncel the .mpdrootignore
---
 src/UpdateWalk.cxx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/UpdateWalk.cxx b/src/UpdateWalk.cxx
index d458645..7634760 100644
--- a/src/UpdateWalk.cxx
+++ b/src/UpdateWalk.cxx
@@ -358,7 +358,11 @@ update_directory(Directory &directory, const struct stat *st)
 	}
 
 	ExcludeList exclude_list;
-	exclude_list.LoadFile(AllocatedPath::Build(path_fs, ".mpdignore"));
+	AllocatedPath root_ignore = mapper_get_music_directory_fs();
+	
+	// if LoadFile return false, file does not exists, fallback to .mpdrootignore
+	if(!exclude_list.LoadFile(AllocatedPath::Build(path_fs, ".mpdignore")))
+		exclude_list.LoadFile(AllocatedPath::Build(root_ignore, ".mpdrootignore"));
 
 	if (!exclude_list.IsEmpty())
 		remove_excluded_from_directory(directory, exclude_list);
-- 
1.8.5.2

_______________________________________________
mpd-devel mailing list
[email protected]
http://mailman.blarg.de/listinfo/mpd-devel

Reply via email to