2001-04-09 22:48:12 +00:00
|
|
|
/*
|
|
|
|
* busybox library eXtendet funcion
|
|
|
|
*
|
|
|
|
* concatenate path and file name to new allocation buffer,
|
|
|
|
* not addition '/' if path name already have '/'
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-29 18:59:32 +00:00
|
|
|
#include <string.h>
|
2001-04-09 22:48:12 +00:00
|
|
|
#include "libbb.h"
|
|
|
|
|
|
|
|
extern char *concat_path_file(const char *path, const char *filename)
|
|
|
|
{
|
|
|
|
char *outbuf;
|
2001-05-15 17:42:16 +00:00
|
|
|
char *lc;
|
2001-07-07 04:27:35 +00:00
|
|
|
|
|
|
|
if (!path)
|
|
|
|
path="";
|
2001-05-15 17:42:16 +00:00
|
|
|
lc = last_char_is(path, '/');
|
2001-05-07 23:01:32 +00:00
|
|
|
if (filename[0] == '/')
|
|
|
|
filename++;
|
|
|
|
outbuf = xmalloc(strlen(path)+strlen(filename)+1+(lc==NULL));
|
2001-07-07 04:27:35 +00:00
|
|
|
sprintf(outbuf, "%s%s%s", path, (lc==NULL)? "/" : "", filename);
|
|
|
|
|
2001-04-09 22:48:12 +00:00
|
|
|
return outbuf;
|
|
|
|
}
|