Bug 785171 - Return success from WriteToFile. r=dhylands
authorThomas Zimmermann <tdz@users.sourceforge.net>
Fri, 14 Sep 2012 11:52:07 -0700
changeset 107212 8e5fe9ad79505f0d171ee838c90d1958e0b00b97
parent 107211 4de50fce24ea2d7423012555035c28d9d45269bb
child 107213 f746375dc95c7e9bc55ff6eedbb7b981342e55a9
push id74
push usershu@rfrn.org
push dateTue, 18 Sep 2012 19:23:47 +0000
reviewersdhylands
bugs785171
milestone18.0a1
Bug 785171 - Return success from WriteToFile. r=dhylands For supporting multiple files in the OOM adjustment, we need to know if a file has been successfully written to. in this case WriteToFile now returns 'true', otherwise it returns 'false'.
hal/gonk/GonkHal.cpp
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -366,29 +366,31 @@ bool ReadFromFile(const char *filename, 
     HAL_LOG(("Error reading from file %s.", filename));
     return false;
   }
 
   buf[PR_MIN(numRead, n - 1)] = '\0';
   return true;
 }
 
-void WriteToFile(const char *filename, const char *toWrite)
+bool WriteToFile(const char *filename, const char *toWrite)
 {
   int fd = open(filename, O_WRONLY);
   ScopedClose autoClose(fd);
   if (fd < 0) {
     HAL_LOG(("Unable to open file %s.", filename));
-    return;
+    return false;
   }
 
   if (write(fd, toWrite, strlen(toWrite)) < 0) {
     HAL_LOG(("Unable to write to file %s.", filename));
-    return;
+    return false;
   }
+
+  return true;
 }
 
 // We can write to screenEnabledFilename to enable/disable the screen, but when
 // we read, we always get "mem"!  So we have to keep track ourselves whether
 // the screen is on or not.
 bool sScreenEnabled = true;
 
 // We can read wakeLockFilename to find out whether the cpu wake lock