1
0
Fork 0

Spectre/System/File: adding readString()

This commit is contained in:
Henrik Hautakoski 2022-09-25 16:31:45 +02:00
parent 99ae7f2236
commit c11d71aaaa
2 changed files with 18 additions and 0 deletions

View file

@ -140,6 +140,21 @@ size_t File::read(void *ptr, size_t size)
return -1;
}
size_t File::readString(std::string &str)
{
if (isOpen()) {
for(;;) {
int c = ::getc(m_handle);
if (c == EOF || c == '\0') {
break;
}
str.push_back(c);
}
return str.length();
}
return -1;
}
size_t File::write(const void *ptr, size_t size)
{
if (isOpen()) {