Commit 62596d7e authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

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'.
parent 04691bc2
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -371,19 +371,21 @@ bool ReadFromFile(const char *filename, char (&buf)[n])
  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