Added a new open method to the directory class, and changed current_is_directory to current_is_dir.

This commit is contained in:
Relintai 2022-02-04 23:25:09 +01:00
parent b38b2f4755
commit 0669bbbe55
2 changed files with 19 additions and 2 deletions

View File

@ -16,6 +16,22 @@ Error Directory::open(const String &path, bool skip_specials) {
return OK;
}
Error Directory::open(const char *path, bool skip_specials) {
if (_open) {
return ERR_CANT_ACQUIRE_RESOURCE;
}
_skip_specials = skip_specials;
if (tinydir_open(&_dir, path) == -1) {
return FAILED;
}
_open = true;
return OK;
}
void Directory::close() {
if (!_open) {
return;
@ -65,7 +81,7 @@ char *Directory::current_get_extension_cstr() {
bool Directory::current_is_file() {
return !_file.is_dir;
}
bool Directory::current_is_directory() {
bool Directory::current_is_dir() {
return _file.is_dir;
}

View File

@ -11,6 +11,7 @@ class Directory : public Reference {
RCPP_OBJECT(Directory, Reference);
public:
Error open(const String &path, bool skip_specials = false);
Error open(const char *path, bool skip_specials = false);
void close();
bool has_next();
@ -24,7 +25,7 @@ public:
char *current_get_path_cstr();
char *current_get_extension_cstr();
bool current_is_file();
bool current_is_directory();
bool current_is_dir();
String read_file(const String &path);
void read_file_into(const String &path, String *str);