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