2001-10-24 10:30:29 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
2001-04-10 04:18:12 +05:30
|
|
|
/*
|
2001-10-24 10:30:29 +05:30
|
|
|
* Utility routines.
|
2001-04-10 04:18:12 +05:30
|
|
|
*
|
2004-03-15 13:59:22 +05:30
|
|
|
* Copyright (C) many different people.
|
2003-07-15 02:51:08 +05:30
|
|
|
* If you wrote this, please acknowledge your work.
|
2001-10-24 10:30:29 +05:30
|
|
|
*
|
2006-07-10 17:11:19 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
2001-10-24 10:30:29 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
/* concatenate path and file name to new allocation buffer,
|
|
|
|
* not addition '/' if path name already have '/'
|
2001-04-10 04:18:12 +05:30
|
|
|
*/
|
|
|
|
|
2001-06-30 00:29:32 +05:30
|
|
|
#include <string.h>
|
2001-04-10 04:18:12 +05:30
|
|
|
#include "libbb.h"
|
|
|
|
|
2006-03-07 02:17:33 +05:30
|
|
|
char *concat_path_file(const char *path, const char *filename)
|
2001-04-10 04:18:12 +05:30
|
|
|
{
|
2001-05-15 23:12:16 +05:30
|
|
|
char *lc;
|
2001-07-07 09:57:35 +05:30
|
|
|
|
|
|
|
if (!path)
|
2005-05-10 03:21:15 +05:30
|
|
|
path = "";
|
2001-05-15 23:12:16 +05:30
|
|
|
lc = last_char_is(path, '/');
|
2001-08-02 10:32:46 +05:30
|
|
|
while (*filename == '/')
|
2001-05-08 04:31:32 +05:30
|
|
|
filename++;
|
2005-09-29 21:48:57 +05:30
|
|
|
return bb_xasprintf("%s%s%s", path, (lc==NULL ? "/" : ""), filename);
|
2001-04-10 04:18:12 +05:30
|
|
|
}
|