aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/directory.c10
-rw-r--r--src/directory.h6
2 files changed, 10 insertions, 6 deletions
diff --git a/src/directory.c b/src/directory.c
index f76dd9c95..25a6bcec8 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -105,11 +105,6 @@ struct directory * directory_get_root(void)
return music_root;
}
-int isRootDirectory(const char *name)
-{
- return (!name || name[0] == '\0' || !strcmp(name, "/"));
-}
-
static struct directory *
getSubDirectory(struct directory * directory, const char *name)
{
@@ -118,6 +113,8 @@ getSubDirectory(struct directory * directory, const char *name)
char *duplicated;
char *locate;
+ assert(name != NULL);
+
if (isRootDirectory(name))
return directory;
@@ -143,6 +140,9 @@ getSubDirectory(struct directory * directory, const char *name)
struct directory * getDirectory(const char *name)
{
+ if (name == NULL)
+ return music_root;
+
return getSubDirectory(music_root, name);
}
diff --git a/src/directory.h b/src/directory.h
index 72de511e7..127da678c 100644
--- a/src/directory.h
+++ b/src/directory.h
@@ -41,7 +41,11 @@ void directory_init(void);
void directory_finish(void);
-int isRootDirectory(const char *name);
+static inline int isRootDirectory(const char *name)
+{
+ /* TODO: verify and remove !name check */
+ return (!name || *name == '\0' || !strcmp(name, "/"));
+}
struct directory * directory_get_root(void);