typo fix
[busybox-git.git] / libbb / concat_path_file.c
blob5b4b7f113110abe51823c57a376bc1c8311e804f
1 /* vi: set sw=4 ts=4: */
2 /*
3 * Utility routines.
5 * Copyright (C) many different people.
6 * If you wrote this, please acknowledge your work.
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */
10 #include "libbb.h"
12 /* Concatenate path and filename to new allocated buffer.
13 * Add '/' only as needed (no duplicate // are produced).
14 * If path is NULL, it is assumed to be "/".
15 * filename should not be NULL.
18 char* FAST_FUNC concat_path_file(const char *path, const char *filename)
20 char *lc;
22 if (!path)
23 path = "";
24 lc = last_char_is(path, '/');
25 while (*filename == '/')
26 filename++;
27 return xasprintf("%s%s%s", path, (lc==NULL ? "/" : ""), filename);