Commit e7c6c5cb authored by rswindell's avatar rswindell
Browse files

Added getfilesizetotal() which calculates the total size of all files matching

the specified path and (optional) wildcards.
parent 6c08c18c
......@@ -816,6 +816,34 @@ ulong DLLCALL getfilecount(const char *inpath, const char* pattern)
return count;
/* Returns number of bytes used by file(s) matching 'inpath' */
uint64_t DLLCALL getfilesizetotal(const char *inpath)
char path[MAX_PATH+1];
glob_t g;
uint gi;
uint64_t total = 0;
SAFECOPY(path, inpath);
if(glob(path, GLOB_MARK, NULL, &g))
return 0;
for(gi = 0; gi < g.gl_pathc; ++gi) {
if(*lastchar(g.gl_pathv[gi]) == '/')
off_t size = flength(g.gl_pathv[gi]);
if(size >= 1)
total += size;
return total;
/* Return free disk space in bytes (up to a maximum of 4GB) */
......@@ -233,6 +233,7 @@ 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);
DLLEXPORT ulong DLLCALL getfreediskspace(const char* path, ulong unit);
DLLEXPORT uint64_t DLLCALL getfilesizetotal(const char *path);
DLLEXPORT long DLLCALL delfiles(const char *inpath, const char *spec, size_t keep);
DLLEXPORT char* DLLCALL backslash(char* path);
DLLEXPORT BOOL DLLCALL wildmatch(const char *fname, const char *spec, BOOL path);
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