diff options
author | Max Kellermann <max@duempel.org> | 2008-10-15 22:35:13 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-15 22:35:13 +0200 |
commit | 8c0060fae44a94bdfe978d8d4a66589f5a03a074 (patch) | |
tree | fde581584c25e5e74d8a8336f54dc61d4a5f67db /src/playlist.c | |
parent | 0b44cad2ce2c6433f395650a5a70cf8b3473673c (diff) | |
download | mpd-8c0060fae44a94bdfe978d8d4a66589f5a03a074.tar.gz mpd-8c0060fae44a94bdfe978d8d4a66589f5a03a074.tar.xz mpd-8c0060fae44a94bdfe978d8d4a66589f5a03a074.zip |
playlist: added support for adding songs not in the music database
Clients which have authenticated via unix socket may add local files
to the MPD playlist, provided that they own the file.
Diffstat (limited to '')
-rw-r--r-- | src/playlist.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/playlist.c b/src/playlist.c index dfbc31514..0dae1a92b 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -521,6 +521,32 @@ static void clearPlayerQueue(void) pc_cancel(); } +enum playlist_result +playlist_append_file(const char *path, int uid, int *added_id) +{ + int ret; + struct stat st; + struct song *song; + + if (uid <= 0) + /* unauthenticated client */ + return PLAYLIST_RESULT_DENIED; + + ret = stat(path, &st); + if (ret < 0) + return PLAYLIST_RESULT_ERRNO; + + if (st.st_uid != (uid_t)uid) + /* client is not owner */ + return PLAYLIST_RESULT_DENIED; + + song = song_file_load(path, NULL); + if (song == NULL) + return PLAYLIST_RESULT_NO_SUCH_SONG; + + return addSongToPlaylist(song, added_id); +} + static struct song * song_by_url(const char *url) { |