Now read_file_into in Directory will return an Error.

This commit is contained in:
Relintai 2022-02-04 23:33:39 +01:00
parent ef06a9e57d
commit 5292da82ba
2 changed files with 10 additions and 4 deletions

View File

@ -101,12 +101,16 @@ String Directory::read_file(const String &path) {
return fd;
}
void Directory::read_file_into(const String &path, String *str) {
ERR_FAIL_COND(!str);
Error Directory::read_file_into(const String &path, String *str) {
if (!str) {
return ERR_PARAMETER_RANGE_ERROR;
}
FILE *f = fopen(path.c_str(), "r");
ERR_FAIL_COND_MSG(!f, "Error opening file! " + path);
if (!f) {
return ERR_FILE_CANT_OPEN;
}
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
@ -116,6 +120,8 @@ void Directory::read_file_into(const String &path, String *str) {
fread(str->dataw(), 1, fsize, f);
fclose(f);
return OK;
}
bool Directory::is_open() {

View File

@ -28,7 +28,7 @@ public:
bool current_is_dir();
String read_file(const String &path);
void read_file_into(const String &path, String *str);
Error read_file_into(const String &path, String *str);
bool is_open();
bool is_closed();