1 /* Concatenate path components.
2 Copyright (C) 2018-2021 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 3 of the License, or any
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Akim Demaille <akim@lrde.epita.fr>. */
22 #include "path-join.h"
24 #include <concat-filename.h> /* xconcatenated_filename */
25 #include <filename.h> /* IS_ABSOLUTE_PATH */
26 #include <xalloc.h> /* xstrdup */
29 xpath_join (const char *path1
, const char *path2
)
31 if (!path2
|| !*path2
)
32 return xstrdup (path1
);
33 else if (IS_ABSOLUTE_PATH (path2
))
34 return xstrdup (path2
);
36 return xconcatenated_filename (path1
, path2
, NULL
);