Spectre/System/File: adding readString()
This commit is contained in:
parent
99ae7f2236
commit
c11d71aaaa
2 changed files with 18 additions and 0 deletions
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue