| 1 | /* Construct a full filename from a directory and a relative filename. |
| 2 | Copyright (C) 2001-2004, 2006-2020 Free Software Foundation, Inc. |
| 3 | |
| 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 |
| 7 | later version. |
| 8 | |
| 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. |
| 13 | |
| 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/>. */ |
| 16 | |
| 17 | /* Written by Bruno Haible <[email protected]>. */ |
| 18 | |
| 19 | #include <config.h> |
| 20 | |
| 21 | /* Specification. */ |
| 22 | #include "concat-filename.h" |
| 23 | |
| 24 | #include "xalloc.h" |
| 25 | |
| 26 | /* Concatenate a directory filename, a relative filename and an optional |
| 27 | suffix. The directory may end with the directory separator. The second |
| 28 | argument may not start with the directory separator (it is relative). |
| 29 | Return a freshly allocated filename. */ |
| 30 | char * |
| 31 | xconcatenated_filename (const char *directory, const char *filename, |
| 32 | const char *suffix) |
| 33 | { |
| 34 | char *result; |
| 35 | |
| 36 | result = concatenated_filename (directory, filename, suffix); |
| 37 | if (result == NULL) |
| 38 | xalloc_die (); |
| 39 | |
| 40 | return result; |
| 41 | } |