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
|
|
|
*
|
2003-07-14 21:21:08 +00:00
|
|
|
* Copyright (C) many different people.
|
|
|
|
* If you wrote this, please acknowledge your work.
|
2001-10-24 05:00:29 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
2001-04-09 22:48:12 +00:00
|
|
|
*
|
2001-10-24 05:00:29 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* concatenate path and file name to new allocation buffer,
|
|
|
|
* not addition '/' if path name already have '/'
|
2001-04-09 22:48:12 +00:00
|
|
|
*/
|
|
|
|
|
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-08-02 05:02:46 +00:00
|
|
|
while (*filename == '/')
|
2001-05-07 23:01:32 +00:00
|
|
|
filename++;
|
2003-03-19 09:13:01 +00:00
|
|
|
bb_xasprintf(&outbuf, "%s%s%s", path, (lc==NULL)? "/" : "", filename);
|
2001-07-07 04:27:35 +00:00
|
|
|
|
2001-04-09 22:48:12 +00:00
|
|
|
return outbuf;
|
|
|
|
}
|