mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-05-06 17:51:36 +02:00
Now read_file_into in Directory will return an Error.
This commit is contained in:
parent
ef06a9e57d
commit
5292da82ba
@ -101,12 +101,16 @@ String Directory::read_file(const String &path) {
|
|||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
void Directory::read_file_into(const String &path, String *str) {
|
Error Directory::read_file_into(const String &path, String *str) {
|
||||||
ERR_FAIL_COND(!str);
|
if (!str) {
|
||||||
|
return ERR_PARAMETER_RANGE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
FILE *f = fopen(path.c_str(), "r");
|
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);
|
fseek(f, 0, SEEK_END);
|
||||||
long fsize = ftell(f);
|
long fsize = ftell(f);
|
||||||
@ -116,6 +120,8 @@ void Directory::read_file_into(const String &path, String *str) {
|
|||||||
|
|
||||||
fread(str->dataw(), 1, fsize, f);
|
fread(str->dataw(), 1, fsize, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Directory::is_open() {
|
bool Directory::is_open() {
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
bool current_is_dir();
|
bool current_is_dir();
|
||||||
|
|
||||||
String read_file(const String &path);
|
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_open();
|
||||||
bool is_closed();
|
bool is_closed();
|
||||||
|
Loading…
Reference in New Issue
Block a user