mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Reworked directory listing. Now only next need to be called in a while loop.
This commit is contained in:
parent
f103739720
commit
8e49115f09
@ -32,12 +32,7 @@ void FileCache::wwwroot_evaluate_dir(const char *path, const bool should_exist)
|
||||
|
||||
ERR_FAIL_COND_MSG(dir->open_dir(path) != OK, "Error opening wwwroot! folder: " + String(path));
|
||||
|
||||
while (dir->has_next()) {
|
||||
if (!dir->read()) {
|
||||
dir->next();
|
||||
continue;
|
||||
}
|
||||
|
||||
while (dir->next()) {
|
||||
if (dir->current_is_file()) {
|
||||
String np = dir->current_get_path_cstr();
|
||||
|
||||
@ -46,14 +41,11 @@ void FileCache::wwwroot_evaluate_dir(const char *path, const bool should_exist)
|
||||
registered_files.insert(np);
|
||||
} else {
|
||||
if (dir->current_is_special_dir()) {
|
||||
dir->next();
|
||||
continue;
|
||||
}
|
||||
|
||||
wwwroot_evaluate_dir(dir->current_get_path_cstr());
|
||||
}
|
||||
|
||||
dir->next();
|
||||
}
|
||||
|
||||
dir->close_dir();
|
||||
|
@ -50,8 +50,32 @@ bool Directory::read() {
|
||||
|
||||
return _read_file_result != -1;
|
||||
}
|
||||
void Directory::next() {
|
||||
bool Directory::next() {
|
||||
if (!_dir.has_next) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool rres = read();
|
||||
while (!rres && _dir.has_next) {
|
||||
tinydir_next(&_dir);
|
||||
rres = read();
|
||||
}
|
||||
|
||||
if (!rres) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_dir.has_next) {
|
||||
tinydir_next(&_dir);
|
||||
}
|
||||
|
||||
// if (_skip_specials && current_is_dir() && current_is_special_dir()) {
|
||||
// return next();
|
||||
// }
|
||||
|
||||
// tinydir_next(&_dir);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Directory::current_is_ok() {
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
|
||||
bool has_next();
|
||||
bool read();
|
||||
void next();
|
||||
bool next();
|
||||
|
||||
bool current_is_ok();
|
||||
String current_get_name();
|
||||
|
@ -52,17 +52,10 @@ void PagedArticle::load() {
|
||||
|
||||
Vector<String> files;
|
||||
|
||||
while (dir->has_next()) {
|
||||
if (!dir->read()) {
|
||||
dir->next();
|
||||
continue;
|
||||
}
|
||||
|
||||
while (dir->next()) {
|
||||
if (dir->current_is_file()) {
|
||||
files.push_back(dir->current_get_name());
|
||||
}
|
||||
|
||||
dir->next();
|
||||
}
|
||||
|
||||
dir->close_dir();
|
||||
|
@ -29,15 +29,9 @@ void PagedArticles::load() {
|
||||
|
||||
ERR_FAIL_COND_MSG(dir->open_dir(folder) != OK, "Error opening PagedArticles::folder! folder: " + folder);
|
||||
|
||||
while (dir->has_next()) {
|
||||
if (!dir->read()) {
|
||||
dir->next();
|
||||
continue;
|
||||
}
|
||||
|
||||
while (dir->next()) {
|
||||
if (dir->current_is_dir()) {
|
||||
if (dir->current_is_special_dir()) {
|
||||
dir->next();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -52,8 +46,6 @@ void PagedArticles::load() {
|
||||
p->set_uri_segment(seg);
|
||||
add_child(p);
|
||||
}
|
||||
|
||||
dir->next();
|
||||
}
|
||||
|
||||
generate_index_page();
|
||||
|
Loading…
Reference in New Issue
Block a user