Network delete fix.

This commit is contained in:
Adam Ierymenko 2016-09-30 13:47:30 -07:00
parent f0794e09b7
commit 0843ed62fa

View file

@ -170,9 +170,11 @@ bool OSUtils::rmDashRf(const char *path)
return true; return true;
dptr = (struct dirent *)0; dptr = (struct dirent *)0;
for(;;) { for(;;) {
if (readdir_r(d,&de,&dptr)) if (readdir_r(d,&de,&dptr) != 0)
break; break;
if ((dptr)&&(strcmp(dptr->d_name,".") != 0)&&(strcmp(dptr->d_name,"..") != 0)) { if (!dptr)
break;
if ((strcmp(dptr->d_name,".") != 0)&&(strcmp(dptr->d_name,"..") != 0)&&(strlen(dptr->d_name) > 0)) {
std::string p(path); std::string p(path);
p.push_back(ZT_PATH_SEPARATOR); p.push_back(ZT_PATH_SEPARATOR);
p.append(dptr->d_name); p.append(dptr->d_name);
@ -180,7 +182,7 @@ bool OSUtils::rmDashRf(const char *path)
if (!rmDashRf(p.c_str())) if (!rmDashRf(p.c_str()))
return false; return false;
} }
} else break; }
} }
closedir(d); closedir(d);
return (rmdir(path) == 0); return (rmdir(path) == 0);