Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Unified Diff: base/files/file_util_posix.cc

Issue 639253004: Allow POSIX callers to specify a new file's mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Return bool instead of int, to accord with in-progress refactoring. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/files/file_util_posix.cc
diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc
index 5a94cef661319e39b98ea10037113371b4a2d2ac..236927f012f62683c56ba5faecea3a6a8355410a 100644
--- a/base/files/file_util_posix.cc
+++ b/base/files/file_util_posix.cc
@@ -693,6 +693,19 @@ int WriteFile(const FilePath& filename, const char* data, int size) {
return bytes_written;
}
+bool WriteFileMode(const FilePath& filename, const char* data, int size,
+ mode_t mode) {
+ ThreadRestrictions::AssertIOAllowed();
+ int fd = HANDLE_EINTR(creat(filename.value().c_str(), mode));
+ if (fd < 0)
+ return -1;
rvargas (doing something else) 2014/10/21 01:05:53 return false
palmer 2014/10/21 01:26:42 Done.
+
+ bool status = WriteFileDescriptor(fd, data, size);
+ if (IGNORE_EINTR(close(fd)) < 0)
rvargas (doing something else) 2014/10/21 01:05:53 nit: Now that we are writing this function from sc
palmer 2014/10/21 01:26:42 Done.
+ return false;
+ return status;
+}
+
bool WriteFileDescriptor(const int fd, const char* data, int size) {
// Allow for partial writes.
ssize_t bytes_written_total = 0;

Powered by Google App Engine
This is Rietveld 408576698