summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmpd/database.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/libmpd/database.rb b/libmpd/database.rb
index 4f08f5c..27efa93 100644
--- a/libmpd/database.rb
+++ b/libmpd/database.rb
@@ -23,7 +23,7 @@ module MPDDatabase
path = String.new
end
- return send_request(command).scan(/^directory: #{path}([^\/]+)\n/).flatten
+ return send_request(command).scan(/^directory: #{path}([^\/]+?)\n/).flatten
end
# Counts the number of songs in the database where _field_ is _value_, as
@@ -39,6 +39,21 @@ module MPDDatabase
return split_and_hash(send_request('find %s "%s"' % [field, value]))
end
+ # Returns all files.
+ # If an argument is specified, list all files in that directory.
+ def files(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(/^file: #{path}([^\/]+?)\n/).flatten
+ end
+
# Finds all songs in the database where _field_ contains _value_.
# Matching is not case-sensitive.
#