diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-12 05:28:25 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-12 05:29:27 -0700 |
commit | 7278e3b2ee49a853b01dc6532bd7067a264f235d (patch) | |
tree | 28e83de310f0c58df226e253a82b0d43ff784497 /src/directory_print.c | |
parent | c87ce02575e0a9d5ac3e50938688187ea28ad400 (diff) | |
parent | c7579ca2d8422f0172537e1ca7d1bd46edfc4f9d (diff) | |
download | mpd-7278e3b2ee49a853b01dc6532bd7067a264f235d.tar.gz mpd-7278e3b2ee49a853b01dc6532bd7067a264f235d.tar.xz mpd-7278e3b2ee49a853b01dc6532bd7067a264f235d.zip |
Merge branch 'ew/directory'
* ew/directory: (21 commits)
update: fix multiple deletes from *vec iterators
directory: children leave parents before being free()ed
directory: always maintain sorted properties vectors
update: simplify the serialized_delete usage a bit
update: remove delete_each_song and clear_directory
directory: directory_free kills all that it contains
update: serialize directory deletions
update: serialize song_free in main thread
dirvec: introduce locking for all iterators
dirvec: use dirvec_for_each where it makes sense
dirvec: add dirvec_for_each iterator
songvec: avoid holding nr_lock during free(3)
update: allow music_root updates to be queued
update: validate in command.c and fix small memory leak
directory: rename isRootDirectory => path_is_music_root
Avoid calling isRootDirectory when we have a directory object
directory: make music_root global and avoid runtime initialization
directory: use mpd_sizeof_str_flex_array for path, too
tag_item: avoid wasting space when struct is unpackable
song: use mpd_sizeof_str_flex_array for song.url
...
[ew: fixed up merge errors with myself when isRootDirectory
went away]
Diffstat (limited to 'src/directory_print.c')
-rw-r--r-- | src/directory_print.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/directory_print.c b/src/directory_print.c index 1c30f1608..d7b42ec59 100644 --- a/src/directory_print.c +++ b/src/directory_print.c @@ -23,25 +23,23 @@ #include "songvec.h" #include "myfprintf.h" -static int dirvec_print(int fd, const struct dirvec *dv) +static int directory_print_info(struct directory *dir, int fd) { - size_t i; - - for (i = 0; i < dv->nr; ++i) { - if (fdprintf(fd, DIRECTORY_DIR "%s\n", - directory_get_path(dv->base[i])) < 0) - return -1; - } + return fdprintf(fd, DIRECTORY_DIR "%s\n", directory_get_path(dir)); +} - return 0; +static int directory_print_info_x(struct directory *dir, void *data) +{ + return directory_print_info(dir, (int)(size_t)data); } int directory_print(int fd, const struct directory *dir) { - if (dirvec_print(fd, &dir->children) < 0) + void *arg = (void *)(size_t)fd; + + if (dirvec_for_each(&dir->children, directory_print_info_x, arg) < 0) return -1; - if (songvec_for_each(&dir->songs, song_print_info_x, - (void *)(size_t)fd) < 0) + if (songvec_for_each(&dir->songs, song_print_info_x, arg) < 0) return -1; return 0; } |