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
|
|
|
*
|
|
|
|
* 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-10 04:18:12 +05:30
|
|
|
*
|
2001-10-24 10:30:29 +05:30
|
|
|
* 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-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"
|
|
|
|
|
|
|
|
extern char *concat_path_file(const char *path, const char *filename)
|
|
|
|
{
|
|
|
|
char *outbuf;
|
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-05-10 03:21:15 +05:30
|
|
|
bb_xasprintf(&outbuf, "%s%s%s", path, (lc==NULL ? "/" : ""), filename);
|
2001-07-07 09:57:35 +05:30
|
|
|
|
2001-04-10 04:18:12 +05:30
|
|
|
return outbuf;
|
|
|
|
}
|