cleanup
parent
1c48de0ccd
commit
a31fbdbe32
|
@ -264,15 +264,8 @@ struct DirectoryStream {
|
||||||
long ret = 0;
|
long ret = 0;
|
||||||
struct dirent rdv;
|
struct dirent rdv;
|
||||||
struct dirent *rd;
|
struct dirent *rd;
|
||||||
for (;;) {
|
while (pop_front(td, &rdv, &rd))
|
||||||
if (readdir_r(td, &rdv, &rd)) {
|
++ret;
|
||||||
closedir(td);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (!rd)
|
|
||||||
break;
|
|
||||||
ret += (strcmp(rd->d_name, ".") && strcmp(rd->d_name, ".."));
|
|
||||||
}
|
|
||||||
closedir(td);
|
closedir(td);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -303,16 +296,20 @@ private:
|
||||||
return !p_de;
|
return !p_de;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pop_front() {
|
static bool pop_front(DIR *d, struct dirent *dev, struct dirent **de) {
|
||||||
if (!p_d) return false;
|
if (!d) return false;
|
||||||
if (readdir_r(p_d, &p_dev, &p_de))
|
if (readdir_r(d, dev, de))
|
||||||
return false;
|
return false;
|
||||||
while (p_de && (!strcmp(p_de->d_name, ".") ||
|
while (*de && (!strcmp((*de)->d_name, ".") ||
|
||||||
!strcmp(p_de->d_name, ".."))) {
|
!strcmp((*de)->d_name, ".."))) {
|
||||||
if (readdir_r(p_d, &p_dev, &p_de))
|
if (readdir_r(d, dev, de))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !!p_de;
|
return !!*de;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pop_front() {
|
||||||
|
return pop_front(p_d, &p_dev, &p_de);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInfo front() const {
|
FileInfo front() const {
|
||||||
|
|
Loading…
Reference in New Issue