| // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "update_engine/file_writer.h" |
| namespace chromeos_update_engine { |
| int DirectFileWriter::Open(const char* path, int flags, mode_t mode) { |
| fd_ = open(path, flags, mode); |
| bool DirectFileWriter::Write(const void* bytes, size_t count) { |
| const char* char_bytes = reinterpret_cast<const char*>(bytes); |
| size_t bytes_written = 0; |
| while (bytes_written < count) { |
| ssize_t rc = write(fd_, char_bytes + bytes_written, |
| CHECK_EQ(bytes_written, count); |
| return bytes_written == count; |
| int DirectFileWriter::Close() { |
| // This can be any negative number that's not -1. This way, this FileWriter |
| // won't be used again for another file. |
| } // namespace chromeos_update_engine |