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:
parent
3b6ff84393
commit
69617438a9
@ -1,6 +1,7 @@
|
|||||||
#include "dirvec.h"
|
#include "dirvec.h"
|
||||||
#include "directory.h"
|
#include "directory.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "path.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -26,8 +27,10 @@ struct directory *dirvec_find(const struct dirvec *dv, const char *path)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
path = mpd_basename(path);
|
||||||
|
|
||||||
for (i = dv->nr; --i >= 0; )
|
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 dv->base[i];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user