Commit 3b6ff843 authored by Max Kellermann's avatar Max Kellermann

directory: added directory_get_name()

directory_get_name() returns the base name of the directory.
parent bc85e92a
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "directory.h" #include "directory.h"
#include "utils.h" #include "utils.h"
#include "path.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
...@@ -49,6 +50,12 @@ directory_free(struct directory *directory) ...@@ -49,6 +50,12 @@ directory_free(struct directory *directory)
/*directory_get_path(NULL); */ /*directory_get_path(NULL); */
} }
const char *
directory_get_name(const struct directory *directory)
{
return mpd_basename(directory->path);
}
void void
directory_prune_empty(struct directory *directory) directory_prune_empty(struct directory *directory)
{ {
......
...@@ -68,6 +68,12 @@ directory_get_path(const struct directory *directory) ...@@ -68,6 +68,12 @@ directory_get_path(const struct directory *directory)
return directory->path; return directory->path;
} }
/**
* Returns the base name of the directory.
*/
const char *
directory_get_name(const struct directory *directory);
static inline struct directory * static inline struct directory *
directory_get_child(const struct directory *directory, const char *name) directory_get_child(const struct directory *directory, const char *name)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment