Commit 5c2c76a6 authored by rswindell's avatar rswindell
Browse files

delfiles() needs to return a signed value (long, not ulong) to indicate

a faliure.
delfiles() now returns a negative result upon any deletion errors.
parent 4ae2199b
......@@ -722,11 +722,13 @@ int removecase(const char *path)
/* Deletes all files in dir 'path' that match file spec 'spec' */
/* Returns number of files deleted or negative on error */
/****************************************************************************/
ulong DLLCALL delfiles(const char *inpath, const char *spec)
long DLLCALL delfiles(const char *inpath, const char *spec)
{
char *path;
char lastch;
uint i,files=0;
size_t i;
long files = 0;
long errors = 0;
glob_t g;
size_t inpath_len=strlen(inpath);
......@@ -747,12 +749,16 @@ ulong DLLCALL delfiles(const char *inpath, const char *spec)
for(i=0;i<g.gl_pathc;i++) {
if(isdir(g.gl_pathv[i]))
continue;
CHMOD(g.gl_pathv[i],S_IWRITE); /* Incase it's been marked RDONLY */
CHMOD(g.gl_pathv[i],S_IWRITE); /* In case it's been marked RDONLY */
if(remove(g.gl_pathv[i])==0)
files++;
else
errors++;
}
globfree(&g);
return(files);
if(errors)
return -errors;
return files;
}
/****************************************************************************/
......
......@@ -231,7 +231,7 @@ DLLEXPORT ulong DLLCALL getfilecount(const char *inpath, const char* spec);
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 ulong DLLCALL delfiles(const char *inpath, const char *spec);
DLLEXPORT long DLLCALL delfiles(const char *inpath, const char *spec);
DLLEXPORT char* DLLCALL backslash(char* path);
DLLEXPORT BOOL DLLCALL wildmatch(const char *fname, const char *spec, BOOL path);
DLLEXPORT BOOL DLLCALL wildmatchi(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