Signed-off-by: Christian Seiler <christ...@iwakd.de> --- src/lxc/utils.c | 19 +++++++++++++++++++ src/lxc/utils.h | 1 + 2 files changed, 20 insertions(+)
diff --git a/src/lxc/utils.c b/src/lxc/utils.c index 2e66585..78b234d 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -658,6 +658,25 @@ char **lxc_normalize_path(const char *path) return components; } +char *lxc_append_paths(const char *first, const char *second) +{ + size_t len = strlen(first) + strlen(second) + 1; + const char *pattern = "%s%s"; + char *result = NULL; + + if (second[0] != '/') { + len += 1; + pattern = "%s/%s"; + } + + result = calloc(1, len); + if (!result) + return NULL; + + snprintf(result, len, pattern, first, second); + return result; +} + bool lxc_string_in_list(const char *needle, const char *haystack, char _sep) { char *token, *str, *saveptr = NULL; diff --git a/src/lxc/utils.h b/src/lxc/utils.h index 9776d18..ba7cfb3 100644 --- a/src/lxc/utils.h +++ b/src/lxc/utils.h @@ -219,6 +219,7 @@ extern char *lxc_string_join(const char *sep, const char **parts, bool use_as_pr * foo//bar -> { foo, bar, NULL } */ extern char **lxc_normalize_path(const char *path); +extern char *lxc_append_paths(const char *first, const char *second); /* Note: the following two functions use strtok(), so they will never * consider an empty element, even if two delimiters are next to * each other. -- 1.7.10.4 ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. Consolidate legacy IT systems to a single system of record for IT 2. Standardize and globalize service processes across IT 3. Implement zero-touch automation to replace manual, redundant tasks http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel