/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of systemd.
-
- Copyright 2014 Lennart Poettering
-***/
#include "sd-path.h"
if (r < 0)
return r;
- if (endswith(h, "/"))
- cc = strappend(h, suffix);
- else
- cc = strjoin(h, "/", suffix);
+ cc = path_join(h, suffix);
if (!cc)
return -ENOMEM;
_cleanup_free_ char *b = NULL;
_cleanup_free_ const char *fn = NULL;
const char *c = NULL;
- char line[LINE_MAX];
size_t n;
int r;
* xdg-user-dirs does upstream */
n = strlen(field);
- FOREACH_LINE(line, f, return -errno) {
+ for (;;) {
+ _cleanup_free_ char *line = NULL;
char *l, *p, *e;
+ r = read_line(f, LONG_LINE_MAX, &line);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ break;
+
l = strstrip(line);
if (!strneq(l, field, n))
}
suffix += strspn(suffix, "/");
-
- if (endswith(ret, "/"))
- cc = strappend(ret, suffix);
- else
- cc = strjoin(ret, "/", suffix);
+ cc = path_join(ret, suffix);
free(buffer);
if (!h && home_suffix) {
e = secure_getenv("HOME");
if (e && path_is_absolute(e)) {
- if (endswith(e, "/"))
- h = strappend(e, home_suffix);
- else
- h = strjoin(e, "/", home_suffix);
+ h = path_join(e, home_suffix);
if (!h) {
strv_free(l);
j = n;
STRV_FOREACH(i, l) {
-
- if (endswith(*i, "/"))
- *j = strappend(*i, suffix);
- else
- *j = strjoin(*i, "/", suffix);
-
+ *j = path_join(*i, suffix);
if (!*j)
return -ENOMEM;