aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dbUtils.c7
-rw-r--r--src/directory.h9
-rw-r--r--src/directory_save.c4
-rw-r--r--src/song.c2
-rw-r--r--src/song_print.c2
-rw-r--r--src/update.c2
6 files changed, 18 insertions, 8 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c
index d73366e67..3677b2ae6 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -64,9 +64,10 @@ static int
printDirectoryInDirectory(struct directory *directory, void *data)
{
struct client *client = data;
- if (!isRootDirectory(directory->path)) {
+
+ if (!directory_is_root(directory))
client_printf(client, "directory: %s\n", directory_get_path(directory));
- }
+
return 0;
}
@@ -374,7 +375,7 @@ sumSavedFilenameMemoryInDirectory(struct directory *dir, void *data)
{
int *sum = data;
- if (isRootDirectory(dir->path))
+ if (directory_is_root(dir))
return 0;
*sum += (strlen(directory_get_path(dir)) + 1
diff --git a/src/directory.h b/src/directory.h
index afe81faad..36f0deb18 100644
--- a/src/directory.h
+++ b/src/directory.h
@@ -71,6 +71,15 @@ directory_get_path(const struct directory *directory)
}
/**
+ * Is this the root directory of the music database?
+ */
+static inline bool
+directory_is_root(const struct directory *directory)
+{
+ return directory->parent == NULL;
+}
+
+/**
* Returns the base name of the directory.
*/
const char *
diff --git a/src/directory_save.c b/src/directory_save.c
index 300b2ec87..50ae21fdf 100644
--- a/src/directory_save.c
+++ b/src/directory_save.c
@@ -36,7 +36,7 @@ directory_save(FILE *fp, struct directory *directory)
size_t i;
int retv;
- if (!isRootDirectory(directory->path)) {
+ if (!directory_is_root(directory)) {
retv = fprintf(fp, "%s%s\n", DIRECTORY_BEGIN,
directory_get_path(directory));
if (retv < 0)
@@ -57,7 +57,7 @@ directory_save(FILE *fp, struct directory *directory)
songvec_save(fp, &directory->songs);
- if (!isRootDirectory(directory->path) &&
+ if (!directory_is_root(directory) &&
fprintf(fp, DIRECTORY_END "%s\n",
directory_get_path(directory)) < 0)
return -1;
diff --git a/src/song.c b/src/song.c
index f56853895..9cbd859f5 100644
--- a/src/song.c
+++ b/src/song.c
@@ -181,7 +181,7 @@ song_get_url(const struct song *song, char *path_max_tmp)
assert(song != NULL);
assert(*song->url);
- if (!song->parent || isRootDirectory(song->parent->path))
+ if (!song_in_database(song) || directory_is_root(song->parent))
strcpy(path_max_tmp, song->url);
else
pfx_dir(path_max_tmp, song->url, strlen(song->url),
diff --git a/src/song_print.c b/src/song_print.c
index 235142b37..60e16f941 100644
--- a/src/song_print.c
+++ b/src/song_print.c
@@ -26,7 +26,7 @@
void
song_print_url(struct client *client, struct song *song)
{
- if (song->parent && !isRootDirectory(song->parent->path)) {
+ if (song_in_database(song) && !directory_is_root(song->parent)) {
client_printf(client, "%s%s/%s\n", SONG_FILE,
directory_get_path(song->parent), song->url);
} else {
diff --git a/src/update.c b/src/update.c
index daf658e68..ec9890f31 100644
--- a/src/update.c
+++ b/src/update.c
@@ -290,7 +290,7 @@ make_subdir(struct directory *parent, const char *name)
if (directory == NULL) {
char path[MPD_PATH_MAX];
- if (isRootDirectory(directory_get_path(parent)))
+ if (directory_is_root(parent))
strcpy(path, name);
else
pfx_dir(path, name, strlen(name),