added byte count limiter for read on MString.

This commit is contained in:
brad Arant 2025-02-14 11:56:11 -08:00
parent 5e6d162a05
commit 3f0a541e80
2 changed files with 9 additions and 1 deletions

View File

@ -278,6 +278,13 @@ namespace coreutils {
write(ch); write(ch);
return *this; return *this;
} }
MString &MString::read(int fd, int count) {
char ch;
while(count-- && ::read(fd, &ch, 1))
write(ch);
return *this;
}
int MString::offset() { int MString::offset() {
return cursor - data; return cursor - data;

View File

@ -231,7 +231,8 @@ namespace coreutils {
/// ///
MString &read(int fd); MString &read(int fd);
MString &read(int fd, int len);
/// ///
/// ///
/// ///