Simplify resolve_relative_filename_generic()

This commit is contained in:
Přemysl Eric Janouch 2016-10-01 04:10:44 +02:00
parent 3cc975bb2a
commit b07d9df5fc
Signed by: p
GPG Key ID: B715679E3A361BE6

View File

@ -3187,29 +3187,21 @@ static char *
resolve_relative_filename_generic
(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++)
{
// As per XDG spec, relative paths are ignored
if (*paths->vector[i] != '/')
continue;
str_reset (&file);
str_append_printf (&file, "%s/%s%s", paths->vector[i], tail, filename);
char *file = xstrdup_printf
("%s/%s%s", paths->vector[i], tail, filename);
struct stat st;
if (!stat (file.str, &st))
{
result = str_steal (&file);
break;
}
if (!stat (file, &st))
return file;
free (file);
}
str_free (&file);
return result;
return NULL;
}
static void