Switch FileWriter::Write to boolean result code.
FileWriter::Write returned either the number of bytes written, or a negative
error code. No clients were doing anything with the result other than checking
for success or failure, and many clients were considering any non-zero result
success.
So, I changed the API to return less information, but just the information the
clients needed. Success or failure.
BUG=chromium-os:8521
TEST=Unittests
Change-Id: I51513d6aa7b704dc27fb90d5fae4dc7118a3f86c
Reviewed-on: https://gerrit.chromium.org/gerrit/11532
Reviewed-by: Andrew de los Reyes <[email protected]>
Tested-by: Don Garrett <[email protected]>
Commit-Ready: Don Garrett <[email protected]>
diff --git a/file_writer.h b/file_writer.h
index a534b96..5fd4c5a 100644
--- a/file_writer.h
+++ b/file_writer.h
@@ -27,9 +27,9 @@
// Wrapper around open. Returns 0 on success or -errno on error.
virtual int Open(const char* path, int flags, mode_t mode) = 0;
- // Wrapper around write. Returns bytes written on success or
- // -errno on error.
- virtual ssize_t Write(const void* bytes, size_t count) = 0;
+ // Wrapper around write. Returns true if all requested bytes
+ // were written, or false on any error, reguardless of progress.
+ virtual bool Write(const void* bytes, size_t count) = 0;
// Wrapper around close. Returns 0 on success or -errno on error.
virtual int Close() = 0;
@@ -47,7 +47,7 @@
virtual ~DirectFileWriter() {}
virtual int Open(const char* path, int flags, mode_t mode);
- virtual ssize_t Write(const void* bytes, size_t count);
+ virtual bool Write(const void* bytes, size_t count);
virtual int Close();
int fd() const { return fd_; }