Chromium Code Reviews

Unified Diff: runtime/bin/file_linux.cc

Issue 9034005: Change the behavior of open on files to not truncate by default (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: runtime/bin/file_linux.cc
diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc
index 2da6307a8eeb420603add998ca0babdb7992a741..665240b652458b0fe8ce8420058e5773828d9b9a 100644
--- a/runtime/bin/file_linux.cc
+++ b/runtime/bin/file_linux.cc
@@ -103,10 +103,13 @@ off_t File::Length() {
}
-File* File::Open(const char* name, bool writable) {
+File* File::Open(const char* name, FileOpenMode mode) {
int flags = O_RDONLY;
- if (writable) {
- flags = (O_RDWR | O_CREAT | O_TRUNC);
+ if ((mode & kWrite) != 0) {
+ flags = (O_RDWR | O_CREAT);
+ }
+ if ((mode & kTruncate) != 0) {
+ flags = flags | O_TRUNC;
}
int fd = open(name, flags, 0666);
if (fd < 0) {

Powered by Google App Engine