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
|
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 {};
|
||||||
|
Loading…
Reference in New Issue
Block a user