Skip to content
Snippets Groups Projects
Commit 306f85ac authored by deuce's avatar deuce
Browse files

If the first char of the path passed to _fullpath is ~, expand to the current value of $HOME

parent 13902aad
No related branches found
No related tags found
No related merge requests found
...@@ -761,14 +761,26 @@ char * DLLCALL _fullpath(char *target, const char *path, size_t size) { ...@@ -761,14 +761,26 @@ char * DLLCALL _fullpath(char *target, const char *path, size_t size) {
*out=0; *out=0;
if(*path != '/') { if(*path != '/') {
p=getcwd(target,size); if(*path == '~') {
p=getenv("HOME");
if(p==NULL || strlen(p)+strlen(path)>=size) if(p==NULL || strlen(p)+strlen(path)>=size)
return(NULL); return(NULL);
strcpy(target,p);
out=strrchr(target,'\0');
path++;
}
else {
p=getcwd(NULL,size);
if(p==NULL || strlen(p)+strlen(path)>=size)
return(NULL);
strcpy(target,p);
free(p);
out=strrchr(target,'\0'); out=strrchr(target,'\0');
*(out++)='/'; *(out++)='/';
*out=0; *out=0;
out--; out--;
} }
}
strncat(target,path,size-1); strncat(target,path,size-1);
/* if(stat(target,&sb)) /* if(stat(target,&sb))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment