Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 31d40696 authored by deuce's avatar deuce

Add a getdirname() function which returns a pointer to the last component

of a path that is surrounded by path delimiters.
Use this with GLOB_MARK to for the directory list.
parent 09b77723
...@@ -150,6 +150,26 @@ char *insensitive_mask(char *mask) ...@@ -150,6 +150,26 @@ char *insensitive_mask(char *mask)
#endif #endif
} }
char *getdirname(char *path)
{
char *p1;
char *p2;
p1=strrchr(path,'/');
#ifdef _WIN32
p2=strrchr(path,'\\');
if(p2 > p1)
p1=p2;
#endif
p2 = path;
if(p1 > path) {
for(p2=p1-1; p2>=path && !IS_PATH_DELIM(*p2); p2--);
if(IS_PATH_DELIM(*p2) && *(p2+1))
p2++;
}
return(p2);
}
char **get_file_opt_list(char **fns, int files, int dirsonly, int root) char **get_file_opt_list(char **fns, int files, int dirsonly, int root)
{ {
char **opts; char **opts;
...@@ -167,7 +187,7 @@ char **get_file_opt_list(char **fns, int files, int dirsonly, int root) ...@@ -167,7 +187,7 @@ char **get_file_opt_list(char **fns, int files, int dirsonly, int root)
for(i=0;i<files;i++) { for(i=0;i<files;i++) {
if(isdir(fns[i])) { if(isdir(fns[i])) {
if(dirsonly) if(dirsonly)
opts[j++]=strdup(getfname(fns[i])); opts[j++]=strdup(getdirname(fns[i]));
} }
else { else {
if(!dirsonly) if(!dirsonly)
...@@ -366,7 +386,7 @@ int filepick(uifcapi_t *api, char *title, struct file_pick *fp, char *dir, char ...@@ -366,7 +386,7 @@ int filepick(uifcapi_t *api, char *title, struct file_pick *fp, char *dir, char
#else #else
//#error Need to do something about root paths (in get_file_opt_list() too!) //#error Need to do something about root paths (in get_file_opt_list() too!)
#endif #endif
if(glob(dglob, 0, NULL, &dgl)!=0) { if(glob(dglob, GLOB_MARK, NULL, &dgl)!=0) {
if(lastpath==NULL) { if(lastpath==NULL) {
fp->files=0; fp->files=0;
retval=-1; retval=-1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment