forked from OctaForge/libostd
empty() public on DirectoryStream
parent
a31fbdbe32
commit
80b6aa588b
|
@ -277,6 +277,10 @@ struct DirectoryStream {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool empty() const {
|
||||||
|
return !p_de;
|
||||||
|
}
|
||||||
|
|
||||||
FileInfo read() {
|
FileInfo read() {
|
||||||
if (!pop_front())
|
if (!pop_front())
|
||||||
return FileInfo();
|
return FileInfo();
|
||||||
|
@ -292,19 +296,14 @@ struct DirectoryStream {
|
||||||
DirectoryRange iter();
|
DirectoryRange iter();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool empty() const {
|
|
||||||
return !p_de;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool pop_front(DIR *d, struct dirent *dev, struct dirent **de) {
|
static bool pop_front(DIR *d, struct dirent *dev, struct dirent **de) {
|
||||||
if (!d) return false;
|
if (!d) return false;
|
||||||
if (readdir_r(d, dev, de))
|
if (readdir_r(d, dev, de))
|
||||||
return false;
|
return false;
|
||||||
while (*de && (!strcmp((*de)->d_name, ".") ||
|
while (*de && (!strcmp((*de)->d_name, ".") ||
|
||||||
!strcmp((*de)->d_name, ".."))) {
|
!strcmp((*de)->d_name, "..")))
|
||||||
if (readdir_r(d, dev, de))
|
if (readdir_r(d, dev, de))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return !!*de;
|
return !!*de;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue