return l;
}
-char **path_strv_canonicalize(char **l) {
+char **path_strv_canonicalize_absolute(char **l, const char *prefix) {
char **s;
unsigned k = 0;
bool enomem = false;
STRV_FOREACH(s, l) {
char *t, *u;
- t = path_make_absolute_cwd(*s);
- free(*s);
- *s = NULL;
-
- if (!t) {
- enomem = true;
+ if (!path_is_absolute(*s))
continue;
+
+ if (prefix) {
+ t = strappend(prefix, *s);
+ free(*s);
+ *s = NULL;
+
+ if (!t) {
+ enomem = true;
+ continue;
+ }
+ } else {
+ t = *s;
+ *s = NULL;
}
errno = 0;
u = t;
else {
free(t);
- if (errno == ENOMEM || !errno)
+ if (errno == ENOMEM || errno == 0)
enomem = true;
continue;
return l;
}
-char **path_strv_canonicalize_uniq(char **l) {
+char **path_strv_canonicalize_absolute_uniq(char **l, const char *prefix) {
+
if (strv_isempty(l))
return l;
- if (!path_strv_canonicalize(l))
+ if (!path_strv_canonicalize_absolute(l, prefix))
return NULL;
return strv_uniq(l);