diff options
author | Max Kellermann <max@duempel.org> | 2008-10-09 15:34:07 +0200 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-11 19:21:49 -0700 |
commit | 4a13e19cebb8d72db6e2db9ffb9f9dbd7194ede9 (patch) | |
tree | e6b44e7f6c3bc4e3d30f3b88739dfb4f37ee2a28 /src/directory.h | |
parent | f2052e7e2ffb5b8ecd15d96a766b5a162a39b2af (diff) | |
download | mpd-4a13e19cebb8d72db6e2db9ffb9f9dbd7194ede9.tar.gz mpd-4a13e19cebb8d72db6e2db9ffb9f9dbd7194ede9.tar.xz mpd-4a13e19cebb8d72db6e2db9ffb9f9dbd7194ede9.zip |
directory: added inline wrappers for accessing children
Some tiny utilities... wrappers like these may become helpful when we
introduce locking.
Diffstat (limited to 'src/directory.h')
-rw-r--r-- | src/directory.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/directory.h b/src/directory.h index c767366a7..d8f86f50c 100644 --- a/src/directory.h +++ b/src/directory.h @@ -62,6 +62,20 @@ static inline const char * directory_get_path(struct directory *dir) return dir->path; } +static inline struct directory * +directory_get_child(const struct directory *directory, const char *name) +{ + return dirvec_find(&directory->children, name); +} + +static inline struct directory * +directory_new_child(struct directory *directory, const char *name) +{ + struct directory *subdir = directory_new(name, directory); + dirvec_add(&directory->children, subdir); + return subdir; +} + void directory_prune_empty(struct directory *directory); struct directory * |