0

Switch to simpler base::WriteFile() variants (106/N)

This CL is part of a batch of CLs to replace the use of the less
friendly base::WriteFile call with simpler variants, which are easier to
read, and less prone to mistakes.

Changes in this particular CL address files under the path
/courgette.

This CL was uploaded by git cl split.

R=huangs@chromium.org

AX-Relnotes: n/a.
Bug: 418837
Change-Id: I36a5a4ac2d8e4069c74f9dafd9e371a67ebb0986
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292056
Auto-Submit: Claudio DeSouza <cdesouza@igalia.com>
Commit-Queue: Will Harris <wfh@chromium.org>
Reviewed-by: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1110012}
This commit is contained in:
Claudio DeSouza
2023-02-25 17:40:39 +00:00
committed by Chromium LUCI CQ
parent 693c729ded
commit e2447a36ab

@ -101,13 +101,11 @@ class BufferedFileReader : public courgette::BasicBuffer {
void WriteSinkToFile(const courgette::SinkStream* sink,
const base::FilePath& output_file) {
int count = base::WriteFile(output_file,
reinterpret_cast<const char*>(sink->Buffer()),
static_cast<int>(sink->Length()));
if (count == -1)
bool success = base::WriteFile(
output_file, base::make_span(sink->Buffer(), sink->Length()));
if (!success) {
Problem("Can't write output.");
if (static_cast<size_t>(count) != sink->Length())
Problem("Incomplete write.");
}
}
bool Supported(const base::FilePath& input_file) {