Skip to content

Commit

Permalink
add command 'lsdirs'
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyape committed Jan 14, 2023
1 parent 030094b commit 8f2e41f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* fix null pointer dereference on bad status format
* add "%kbitrate%", "%audioformat%", "%samplerate%", "%bits%" and "%channels%" options to the "status" command
* the "%state%" option of the "status" command now returns "stopped" when the MPD server is stopped
* add command "lsdirs"

0.34 (2021/11/30)
* add commands "albumart", "readpicture"
Expand Down
4 changes: 4 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ Database Commands
``directory``. If no ``directory`` is specified, lists all files in
music directory.

:command:`lsdirs [<directory>]` - List subdirectories of
``directory``. If no ``directory`` is specified, lists subdirectories
in music directory.

:command:`search <type> <query> [<type> <query>]...` - Searches for
substrings in song tags. Any number of tag type and query
combinations can be specified. Possible tag types are: artist,
Expand Down
9 changes: 9 additions & 0 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,15 @@ cmd_lsplaylists(int argc, char **argv, struct mpd_connection *conn)
return ls_entity(argc, argv, conn, MPD_ENTITY_TYPE_PLAYLIST);
}

int
cmd_lsdirs(int argc, char **argv, struct mpd_connection *conn)
{
for (int i = 0; i < argc; i++)
strip_trailing_slash(argv[i]);

return ls_entity(argc, argv, conn, MPD_ENTITY_TYPE_DIRECTORY);
}

int
cmd_load(int argc, char **argv, struct mpd_connection *conn)
{
Expand Down
1 change: 1 addition & 0 deletions src/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int cmd_move(int argc, char **argv, struct mpd_connection *conn);
int cmd_listall(int argc, char **argv, struct mpd_connection *conn);
int cmd_ls(int argc, char **argv, struct mpd_connection *conn);
int cmd_lsplaylists(int argc, char **argv, struct mpd_connection *conn);
int cmd_lsdirs(int argc, char **argv, struct mpd_connection *conn);
int cmd_load(int argc, char **argv, struct mpd_connection *conn);
int cmd_list(int argc, char **argv, struct mpd_connection *conn);
int cmd_save(int argc, char **argv, struct mpd_connection *conn);
Expand Down
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static const struct command {
{"loadtab", 1, 1, 0, cmd_loadtab, "<directory>", NULL}, /* loadtab, lstab, and tab used for completion-scripting only */
{"ls", 0, -1, 2, cmd_ls, "[<directory>]", "List the contents of <directory>"},
{"lsplaylists", 0, -1, 2, cmd_lsplaylists, "", "List currently available playlists"},
{"lsdirs", 0, -1, 2, cmd_lsdirs, "[<directory>]", "List subdirectories of <directory>"},
{"lstab", 1, 1, 0, cmd_lstab, "<directory>", NULL},
{"makepart", 1, -1, 0, cmd_partitionmake, "<name> ...", "Create partition(s)"},
{"mixrampdb", 0, 1, 0, cmd_mixrampdb, "[<dB>]", "Set and display mixrampdb settings"},
Expand Down

0 comments on commit 8f2e41f

Please sign in to comment.