aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-03-06 21:35:05 +0100
committerMax Kellermann <max@duempel.org>2012-03-06 22:23:10 +0100
commit351ac4a2c0a6dfa0774e98d9b5a3d9db33e01274 (patch)
treeeb9d3b5ee88707455c4b3252e3b2562ab78b5fea
parent36fff59a38d8771a173ae21b94186bc99ab11724 (diff)
command: read arbitrary local files with "lsinfo"
Requires UNIX domain socket connection.
-rw-r--r--doc/protocol.xml5
-rw-r--r--src/command.c23
2 files changed, 27 insertions, 1 deletions
diff --git a/doc/protocol.xml b/doc/protocol.xml
index 1ddbc016..56ff33b1 100644
--- a/doc/protocol.xml
+++ b/doc/protocol.xml
@@ -1556,6 +1556,11 @@ OK
the list of stored playlists. This behavior is
deprecated; use "listplaylists" instead.
</para>
+ <para>
+ Clients that are connected via UNIX domain socket may
+ use this command to read the tags of an arbitrary local
+ file (URI beginning with "file:///").
+ </para>
</listitem>
</varlistentry>
<varlistentry id="command_search">
diff --git a/src/command.c b/src/command.c
index 79373796..7d440339 100644
--- a/src/command.c
+++ b/src/command.c
@@ -59,12 +59,13 @@
#include "replay_gain_config.h"
#include "idle.h"
#include "mapper.h"
+#include "song.h"
+#include "song_print.h"
#ifdef ENABLE_SQLITE
#include "sticker.h"
#include "sticker_print.h"
#include "song_sticker.h"
-#include "song_print.h"
#endif
#include <assert.h>
@@ -664,6 +665,26 @@ handle_lsinfo(struct client *client, int argc, char *argv[])
/* default is root directory */
uri = "";
+ if (strncmp(uri, "file:///", 8) == 0) {
+ /* print information about an arbitrary local file */
+ const char *path = uri + 7;
+
+ GError *error = NULL;
+ if (!client_allow_file(client, path, &error))
+ return print_error(client, error);
+
+ struct song *song = song_file_load(path, NULL);
+ if (song == NULL) {
+ command_error(client, ACK_ERROR_NO_EXIST,
+ "No such file");
+ return COMMAND_RETURN_ERROR;
+ }
+
+ song_print_info(client, song);
+ song_free(song);
+ return COMMAND_RETURN_OK;
+ }
+
struct db_selection selection;
db_selection_init(&selection, uri, false);