--- sbbs/src/xpdev/dirwrap.c 2018/04/24 16:41:24 1.1.1.1 +++ sbbs/src/xpdev/dirwrap.c 2018/04/24 16:45:33 1.1.1.2 @@ -2,13 +2,13 @@ /* Directory-related system-call wrappers */ -/* $Id: dirwrap.c,v 1.1.1.1 2018/04/24 16:41:24 root Exp $ */ +/* $Id: dirwrap.c,v 1.1.1.2 2018/04/24 16:45:33 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -175,7 +175,7 @@ int DLLCALL glob(const char *pattern, in glob->gl_pathv=NULL; } - if(_dos_findfirst((char*)pattern,_A_NORMAL,&ff)!=0) + if(_dos_findfirst((char*)pattern,(flags&GLOB_PERIOD) ? _A_HIDDEN : _A_NORMAL,&ff)!=0) return(GLOB_NOMATCH); do { @@ -236,7 +236,7 @@ int DLLCALL glob(const char *pattern, in ff_handle=_findfirst((char*)pattern,&ff); while(ff_handle!=-1) { - if((flags&GLOB_PERIOD || ff.name[0]!='.') && + if((flags&GLOB_PERIOD || (ff.name[0]!='.' && !(ff.attrib&_A_HIDDEN))) && (!(flags&GLOB_ONLYDIR) || ff.attrib&_A_SUBDIR)) { if((new_pathv=(char**)realloc(glob->gl_pathv ,(glob->gl_pathc+1)*sizeof(char*)))==NULL) { @@ -300,6 +300,36 @@ void DLLCALL globfree(glob_t* glob) #endif /* !defined(__unix__) */ +long DLLCALL getdirsize(const char* path, BOOL include_subdirs, BOOL subdir_only) +{ + char match[MAX_PATH+1]; + glob_t g; + unsigned gi; + long count=0; + + if(!isdir(path)) + return -1; + + SAFECOPY(match,path); + backslash(match); + strcat(match,ALLFILES); + glob(match,GLOB_MARK,NULL,&g); + if(include_subdirs && !subdir_only) + count=g.gl_pathc; + else + for(gi=0;gi= fnamep;wildend--) { + if(wildmatch(wildend, specp, path)) + return(TRUE); } + return(FALSE); default: if(*specp != *fnamep) return(FALSE); @@ -1003,7 +1054,7 @@ BOOL DLLCALL wildmatchi(const char *fnam /****************************************************************************/ /* Creates all the necessary directories in the specified path */ /****************************************************************************/ -int DLLCALL mkdirs(const char* path) +int DLLCALL mkpath(const char* path) { const char* p=path; const char* tp;