Skip to content
Snippets Groups Projects
Commit b3eac84d authored by rswindell's avatar rswindell
Browse files

Change getfilecount() to allow the pattern to be specified (or not) in the path

argument, eliminate the spec/pattern argument.
parent 93f4f04b
No related branches found
No related tags found
No related merge requests found
......@@ -449,7 +449,7 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode)
if(strncmp(sp, "FILES:", 6) == 0) { // Number of files in specified directory
const char* path = getpath(&cfg, sp + 6);
safe_snprintf(str, maxlen, "%lu", getfilecount(path, ALLFILES));
safe_snprintf(str, maxlen, "%lu", getfilecount(path));
return str;
}
......
......@@ -792,10 +792,10 @@ long DLLCALL delfiles(const char *inpath, const char *spec, size_t keep)
}
/****************************************************************************/
/* Returns number of files in a directory (inpath) matching 'pattern' */
/* Returns number of files matching 'inpath' */
/* Similar, but not identical, to getdirsize(), e.g. subdirs never counted */
/****************************************************************************/
ulong DLLCALL getfilecount(const char *inpath, const char* pattern)
ulong DLLCALL getfilecount(const char *inpath)
{
char path[MAX_PATH+1];
glob_t g;
......@@ -803,8 +803,10 @@ ulong DLLCALL getfilecount(const char *inpath, const char* pattern)
ulong count = 0;
SAFECOPY(path, inpath);
if(isdir(path))
backslash(path);
SAFECAT(path, pattern);
if(IS_PATH_DELIM(*lastchar(path)))
SAFECAT(path, ALLFILES);
if(glob(path, GLOB_MARK, NULL, &g))
return 0;
for(gi = 0; gi < g.gl_pathc; ++gi) {
......
......@@ -228,7 +228,7 @@ DLLEXPORT char* DLLCALL getfname(const char* path);
DLLEXPORT char* DLLCALL getfext(const char* path);
DLLEXPORT int DLLCALL getfattr(const char* filename);
DLLEXPORT int DLLCALL getfmode(const char* filename);
DLLEXPORT ulong DLLCALL getfilecount(const char *inpath, const char* spec);
DLLEXPORT ulong DLLCALL getfilecount(const char *path);
DLLEXPORT char* DLLCALL getdirname(const char* path);
DLLEXPORT long DLLCALL getdirsize(const char* path, BOOL include_subdirs, BOOL subdir_only);
DLLEXPORT ulong DLLCALL getdisksize(const char* path, ulong unit);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment