cat: Read into buffers instead of lines
This commit is contained in:
parent
fe11b04832
commit
407e81b107
@ -14,11 +14,12 @@ static Result<void> do_cat(StringView path)
|
||||
else
|
||||
f = TRY(File::open(path, File::ReadOnly));
|
||||
|
||||
auto buf = TRY(Buffer::create_sized(4096));
|
||||
while (1)
|
||||
{
|
||||
String line = TRY(f->read_line());
|
||||
if (line.is_empty()) break;
|
||||
out->write(line.view());
|
||||
TRY(f->read(buf, 4096));
|
||||
if (buf.is_empty()) break;
|
||||
out->write(buf);
|
||||
}
|
||||
|
||||
return {};
|
||||
|
Loading…
Reference in New Issue
Block a user