cat: Read into buffers instead of lines

This commit is contained in:
apio 2023-04-18 16:41:58 +02:00
parent fe11b04832
commit 407e81b107
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -14,11 +14,12 @@ static Result<void> do_cat(StringView path)
else else
f = TRY(File::open(path, File::ReadOnly)); f = TRY(File::open(path, File::ReadOnly));
auto buf = TRY(Buffer::create_sized(4096));
while (1) while (1)
{ {
String line = TRY(f->read_line()); TRY(f->read(buf, 4096));
if (line.is_empty()) break; if (buf.is_empty()) break;
out->write(line.view()); out->write(buf);
} }
return {}; return {};