Util: Add patht function to transform path: '~/' is now allowed
This commit is contained in:
18
src/util.c
18
src/util.c
@@ -340,3 +340,21 @@ clean_value(char *str)
|
||||
return p;
|
||||
}
|
||||
|
||||
/* To use ~/ shortcut.. */
|
||||
char*
|
||||
patht(char *path)
|
||||
{
|
||||
static char ret[512];
|
||||
|
||||
if(!path)
|
||||
return NULL;
|
||||
|
||||
strcpy(ret, path);
|
||||
|
||||
if(strstr(path, "~/"))
|
||||
sprintf(ret, "%s/%s", getenv("HOME"), path + 2);
|
||||
|
||||
printf("--> (%s) - %s\n", path, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user