Refactor AppendToFile and WriteFileDescriptor

- Unify the behavior of the windows and posix implementations of these
  functions.
- Simplify the interface by having them just indicate success or failure
  instead of making callers deal with partial writes.

BUG=418837

Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>

Review URL: https://codereview.chromium.org/614893004

Cr-Commit-Position: refs/heads/master@{#298604}


CrOS-Libchrome-Original-Commit: 75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e
diff --git a/base/files/file_util.h b/base/files/file_util.h
index feebeed..ecc0d58 100644
--- a/base/files/file_util.h
+++ b/base/files/file_util.h
@@ -326,14 +326,16 @@
                           int size);
 
 #if defined(OS_POSIX)
-// Append the data to |fd|. Does not close |fd| when done.
-BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size);
+// Appends |data| to |fd|. Does not close |fd| when done.  Returns true iff
+// |size| bytes of |data| were written to |fd|.
+BASE_EXPORT bool WriteFileDescriptor(const int fd, const char* data, int size);
 #endif
 
-// Append the given buffer into the file. Returns the number of bytes written,
-// or -1 on error.
-BASE_EXPORT int AppendToFile(const FilePath& filename,
-                             const char* data, int size);
+// Appends |data| to |filename|.  Returns true iff |size| bytes of |data| were
+// written to |filename|.
+BASE_EXPORT bool AppendToFile(const FilePath& filename,
+                              const char* data,
+                              int size);
 
 // Gets the current working directory for the process.
 BASE_EXPORT bool GetCurrentDirectory(FilePath* path);