Renamed a few method in Directory.

This commit is contained in:
Relintai 2022-02-04 23:36:04 +01:00
parent 52f85862bd
commit 5097d210d3
4 changed files with 26 additions and 26 deletions

View File

@ -30,7 +30,7 @@ void FileCache::wwwroot_evaluate_dir(const char *path, const bool should_exist)
Ref<Directory> dir;
dir.instance();
ERR_FAIL_COND_MSG(!dir->open(path, true), "Error opening wwwroot! folder: " + String(path));
ERR_FAIL_COND_MSG(!dir->open_dir(path, true), "Error opening wwwroot! folder: " + String(path));
while (dir->has_next()) {
@ -46,7 +46,7 @@ void FileCache::wwwroot_evaluate_dir(const char *path, const bool should_exist)
}
}
dir->close();
dir->close_dir();
}
bool FileCache::get_cached_body(const String &path, String *body) {

View File

@ -1,7 +1,7 @@
#include "directory.h"
Error Directory::open(const String &path, bool skip_specials) {
if (_open) {
Error Directory::open_dir(const String &path, bool skip_specials) {
if (_dir_open) {
return ERR_CANT_ACQUIRE_RESOURCE;
}
@ -11,13 +11,13 @@ Error Directory::open(const String &path, bool skip_specials) {
return FAILED;
}
_open = true;
_dir_open = true;
return OK;
}
Error Directory::open(const char *path, bool skip_specials) {
if (_open) {
Error Directory::open_dir(const char *path, bool skip_specials) {
if (_dir_open) {
return ERR_CANT_ACQUIRE_RESOURCE;
}
@ -27,19 +27,19 @@ Error Directory::open(const char *path, bool skip_specials) {
return FAILED;
}
_open = true;
_dir_open = true;
return OK;
}
void Directory::close() {
if (!_open) {
void Directory::close_dir() {
if (!_dir_open) {
return;
}
tinydir_close(&_dir);
_open = false;
_dir_open = false;
}
bool Directory::has_next() {
@ -124,20 +124,20 @@ Error Directory::read_file_into(const String &path, String *str) {
return OK;
}
bool Directory::is_open() {
return _open;
bool Directory::is_dir_open() {
return _dir_open;
}
bool Directory::is_closed() {
return !_open;
bool Directory::is_dir_closed() {
return !_dir_open;
}
Directory::Directory() {
_skip_specials = false;
_read_file_result = 0;
_open = false;
_dir_open = false;
}
Directory::~Directory() {
if (is_open()) {
close();
if (is_dir_open()) {
close_dir();
}
}

View File

@ -10,9 +10,9 @@
class Directory : public Reference {
RCPP_OBJECT(Directory, Reference);
public:
Error open(const String &path, bool skip_specials = true);
Error open(const char *path, bool skip_specials = true);
void close();
Error open_dir(const String &path, bool skip_specials = true);
Error open_dir(const char *path, bool skip_specials = true);
void close_dir();
bool has_next();
void next();
@ -30,8 +30,8 @@ public:
String read_file(const String &path);
Error read_file_into(const String &path, String *str);
bool is_open();
bool is_closed();
bool is_dir_open();
bool is_dir_closed();
Directory();
virtual ~Directory();
@ -42,7 +42,7 @@ private:
tinydir_dir _dir;
tinydir_file _file;
bool _open;
bool _dir_open;
};
#endif

View File

@ -47,7 +47,7 @@ void PagedArticle::load() {
Ref<Directory> dir;
dir.instance();
ERR_FAIL_COND_MSG(!dir->open(articles_folder.c_str(), false), "Error opening PagedArticle::folder! folder: " + articles_folder);
ERR_FAIL_COND_MSG(!dir->open_dir(articles_folder.c_str(), false), "Error opening PagedArticle::folder! folder: " + articles_folder);
Vector<String> files;
@ -59,7 +59,7 @@ void PagedArticle::load() {
}
}
dir->close();
dir->close_dir();
if (files.size() == 0) {
return;