Failing to delete a file in recursively was bailing out prematurely

This commit is contained in:
Pierre Pronchery 2007-06-20 03:03:57 +00:00
parent 09bd4adb64
commit ee6c7787cd

View File

@ -95,6 +95,7 @@ static int _rm_do(Prefs * prefs, char * file)
static int _rm_do_recursive(Prefs * prefs, char * file) static int _rm_do_recursive(Prefs * prefs, char * file)
{ {
int ret = 0;
DIR * dir; DIR * dir;
struct dirent * de; struct dirent * de;
size_t len = strlen(file) + 2; size_t len = strlen(file) + 2;
@ -123,16 +124,15 @@ static int _rm_do_recursive(Prefs * prefs, char * file)
} }
path = p; path = p;
strcpy(&path[len - 1], de->d_name); strcpy(&path[len - 1], de->d_name);
if(_rm_do(prefs, path) != 0) ret |= _rm_do(prefs, path);
return 1;
} }
free(path); free(path);
closedir(dir); closedir(dir);
if(*prefs & PREFS_i && !_rm_confirm(file, "directory")) if(*prefs & PREFS_i && !_rm_confirm(file, "directory"))
return 0; return ret;
if(rmdir(file) != 0) if(rmdir(file) != 0)
return _rm_error(file, 1); return _rm_error(file, 1);
return 0; return ret;
} }