Simplify resolve_relative_filename_generic()
This commit is contained in:
parent
3cc975bb2a
commit
b07d9df5fc
20
liberty.c
20
liberty.c
@ -3187,29 +3187,21 @@ static char *
|
|||||||
resolve_relative_filename_generic
|
resolve_relative_filename_generic
|
||||||
(struct str_vector *paths, const char *tail, const char *filename)
|
(struct str_vector *paths, const char *tail, const char *filename)
|
||||||
{
|
{
|
||||||
struct str file;
|
|
||||||
str_init (&file);
|
|
||||||
|
|
||||||
char *result = NULL;
|
|
||||||
for (unsigned i = 0; i < paths->len; i++)
|
for (unsigned i = 0; i < paths->len; i++)
|
||||||
{
|
{
|
||||||
// As per XDG spec, relative paths are ignored
|
// As per XDG spec, relative paths are ignored
|
||||||
if (*paths->vector[i] != '/')
|
if (*paths->vector[i] != '/')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
str_reset (&file);
|
char *file = xstrdup_printf
|
||||||
str_append_printf (&file, "%s/%s%s", paths->vector[i], tail, filename);
|
("%s/%s%s", paths->vector[i], tail, filename);
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (!stat (file.str, &st))
|
if (!stat (file, &st))
|
||||||
{
|
return file;
|
||||||
result = str_steal (&file);
|
free (file);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
str_free (&file);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user