diff options
author | J. Alexander Treuman <jat@spatialrift.net> | 2007-05-24 17:06:59 +0000 |
---|---|---|
committer | J. Alexander Treuman <jat@spatialrift.net> | 2007-05-24 17:06:59 +0000 |
commit | c408bd5e903da0441f461aa564095ec581cb3cfd (patch) | |
tree | 40e464e712dbed7b55f45bc9f62b3b11388e31fe | |
parent | 93b96edacc4a3a3e0ca32bec6cdbf96a1c068850 (diff) | |
download | mpd-c408bd5e903da0441f461aa564095ec581cb3cfd.tar.gz mpd-c408bd5e903da0441f461aa564095ec581cb3cfd.tar.xz mpd-c408bd5e903da0441f461aa564095ec581cb3cfd.zip |
Don't list playlists in lsinfo if the path isn't the root directory (they
can't be loaded anyway).
git-svn-id: https://svn.musicpd.org/mpd/trunk@6244 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r-- | src/command.c | 23 | ||||
-rw-r--r-- | src/directory.c | 10 | ||||
-rw-r--r-- | src/directory.h | 2 |
3 files changed, 23 insertions, 12 deletions
diff --git a/src/command.c b/src/command.c index 107df3275..c8f39472d 100644 --- a/src/command.c +++ b/src/command.c @@ -402,17 +402,18 @@ static int handleListPlaylistInfo(int fd, int *permission, static int handleLsInfo(int fd, int *permission, int argc, char *argv[]) { - if (argc == 1) { - if (printDirectoryInfo(fd, NULL) < 0) - return -1; - else - return lsPlaylists(fd, ""); - } else { - if (printDirectoryInfo(fd, argv[1]) < 0) - return -1; - else - return lsPlaylists(fd, argv[1]); - } + char *path = ""; + + if (argc == 2) + path = argv[1]; + + if (printDirectoryInfo(fd, path) < 0) + return -1; + + if (isRootDirectory(path)) + return lsPlaylists(fd, path); + + return 0; } static int handleRm(int fd, int *permission, int argc, char *argv[]) diff --git a/src/directory.c b/src/directory.c index 4c94e6be9..fb18ff91b 100644 --- a/src/directory.c +++ b/src/directory.c @@ -835,13 +835,21 @@ static Directory *findSubDirectory(Directory * directory, char *name) return NULL; } +int isRootDirectory(char *name) +{ + if (name == NULL || name[0] == '\0' || strcmp(name, "/") == 0) { + return 1; + } + return 0; +} + static Directory *getSubDirectory(Directory * directory, char *name, char **shortname) { Directory *subDirectory; int len; - if (name == NULL || name[0] == '\0' || strcmp(name, "/") == 0) { + if (isRootDirectory(name)) { return directory; } diff --git a/src/directory.h b/src/directory.h index df682c3db..b1482988f 100644 --- a/src/directory.h +++ b/src/directory.h @@ -51,6 +51,8 @@ void initMp3Directory(void); void closeMp3Directory(void); +int isRootDirectory(char *name); + int printDirectoryInfo(int fd, char *dirname); int checkDirectoryDB(void); |