summaryrefslogtreecommitdiff
path: root/libmpd
diff options
context:
space:
mode:
Diffstat (limited to 'libmpd')
-rw-r--r--libmpd/database.rb15
1 files changed, 15 insertions, 0 deletions
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)