1/* 2 * busybox library eXtendet funcion 3 * 4 * concatenate path and file name to new allocation buffer, 5 * not addition '/' if path name already have '/' 6 * 7*/ 8 9#include <string.h> 10#include "libbb.h" 11 12extern char *concat_path_file(const char *path, const char *filename) 13{ 14 char *outbuf; 15 char *lc; 16 17 if (!path) 18 path=""; 19 lc = last_char_is(path, '/'); 20 while (*filename == '/') 21 filename++; 22 outbuf = xmalloc(strlen(path)+strlen(filename)+1+(lc==NULL)); 23 sprintf(outbuf, "%s%s%s", path, (lc==NULL)? "/" : "", filename); 24 25 return outbuf; 26} 27