From af6101f5e39310445e831554a62c449148476e01 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 1 Aug 2009 16:23:35 -0700 Subject: Add a new directories method to database methods. --- libmpd/database.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libmpd/database.rb') diff --git a/libmpd/database.rb b/libmpd/database.rb index 00cc693..4f08f5c 100644 --- a/libmpd/database.rb +++ b/libmpd/database.rb @@ -11,6 +11,21 @@ # Collection of methods related to the database. module MPDDatabase + # Returns all directories. + # If an argument is specified, list all subdirectories of that directory. + def directories(uri=nil) + command = 'listall' + command << ' "%s"' % uri if uri + + if uri + path = Regexp.escape(uri + '/') + else + path = String.new + end + + return send_request(command).scan(/^directory: #{path}([^\/]+)\n/).flatten + end + # Counts the number of songs in the database where _field_ is _value_, as # well as their total playtime. def count(field, value) -- cgit v1.2.3-70-g09d2