assert(p);
- if ((r = strrchr(p, '/')))
+ r = strrchr(p, '/');
+ if (r)
return r + 1;
return (char*) p;
char **l;
assert(p);
- if (!(l = strv_split(p, ":")))
+ l = strv_split(p, ":");
+ if (!l)
return NULL;
if (!path_strv_make_absolute_cwd(l)) {
}
char *path_make_absolute_cwd(const char *p) {
- char *cwd, *r;
+ _cleanup_free_ char *cwd = NULL;
assert(p);
if (!cwd)
return NULL;
- r = path_make_absolute(p, cwd);
- free(cwd);
-
- return r;
+ return path_make_absolute(p, cwd);
}
char **path_strv_make_absolute_cwd(char **l) {
STRV_FOREACH(s, l) {
char *t;
- if (!(t = path_make_absolute_cwd(*s)))
+ t = path_make_absolute_cwd(*s);
+ if (!t)
return NULL;
free(*s);
return l;
}
+char **path_strv_canonicalize_uniq(char **l) {
+ if (strv_isempty(l))
+ return l;
+
+ if (!path_strv_canonicalize(l))
+ return NULL;
+
+ return strv_uniq(l);
+}
+
char *path_kill_slashes(char *path) {
char *f, *t;
bool slash = false;
return !!(st.f_flag & ST_RDONLY);
}
+
+int path_is_os_tree(const char *path) {
+ char *p;
+ int r;
+
+ /* We use /etc/os-release as flag file if something is an OS */
+
+ p = strappenda(path, "/etc/os-release");
+ r = access(p, F_OK);
+
+ return r < 0 ? 0 : 1;
+}