dirvec: dirvec_find() compares basename

It is invalid to pass a path with the wrong dirname to dirvec_find().
To be able to find a subdirectory only by its basename, compare only
the basename of both paths.
This commit is contained in:
Max Kellermann 2008-10-13 16:33:04 +02:00
parent 3b6ff84393
commit 69617438a9

View File

@ -1,6 +1,7 @@
#include "dirvec.h"
#include "directory.h"
#include "utils.h"
#include "path.h"
#include <string.h>
@ -26,8 +27,10 @@ struct directory *dirvec_find(const struct dirvec *dv, const char *path)
{
int i;
path = mpd_basename(path);
for (i = dv->nr; --i >= 0; )
if (!strcmp(dv->base[i]->path, path))
if (!strcmp(directory_get_name(dv->base[i]), path))
return dv->base[i];
return NULL;
}