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

Unified Diff: runtime/bin/file_macos.cc

Issue 1193653002: Add file modes for opening a file write only (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Addressed review comments + fixed analyzer reported issues Created 5 years, 6 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
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_macos.cc
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc
index 9fc33c5b4936a56b4e36c30b3ac61fc3c8a0c771..ddc19cc029794e899f4c336332d2dcb251ebdcdd 100644
--- a/runtime/bin/file_macos.cc
+++ b/runtime/bin/file_macos.cc
@@ -159,8 +159,13 @@ File* File::Open(const char* name, FileOpenMode mode) {
}
int flags = O_RDONLY;
if ((mode & kWrite) != 0) {
+ ASSERT((mode & kWriteOnly) == 0);
flags = (O_RDWR | O_CREAT);
}
+ if ((mode & kWriteOnly) != 0) {
+ ASSERT((mode & kWrite) == 0);
+ flags = (O_WRONLY | O_CREAT);
+ }
if ((mode & kTruncate) != 0) {
flags = flags | O_TRUNC;
}
@@ -169,7 +174,8 @@ File* File::Open(const char* name, FileOpenMode mode) {
return NULL;
}
FDUtils::SetCloseOnExec(fd);
- if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) {
+ if ((((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) ||
+ (((mode & kWriteOnly) != 0) && ((mode & kTruncate) == 0))) {
int64_t position = lseek(fd, 0, SEEK_END);
if (position < 0) {
return NULL;
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698