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

Side by Side Diff: runtime/bin/file_macos.cc

Issue 9346015: Change file opening operation to set position at the end of the file when FileMode.APPEND is used. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/file.h" 5 #include "bin/file.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if ((mode & kWrite) != 0) { 110 if ((mode & kWrite) != 0) {
111 flags = (O_RDWR | O_CREAT); 111 flags = (O_RDWR | O_CREAT);
112 } 112 }
113 if ((mode & kTruncate) != 0) { 113 if ((mode & kTruncate) != 0) {
114 flags = flags | O_TRUNC; 114 flags = flags | O_TRUNC;
115 } 115 }
116 int fd = TEMP_FAILURE_RETRY(open(name, flags, 0666)); 116 int fd = TEMP_FAILURE_RETRY(open(name, flags, 0666));
117 if (fd < 0) { 117 if (fd < 0) {
118 return NULL; 118 return NULL;
119 } 119 }
120 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) {
121 int position = TEMP_FAILURE_RETRY(lseek(fd, 0, SEEK_END));
122 ASSERT(position >= 0);
123 }
120 return new File(name, new FileHandle(fd)); 124 return new File(name, new FileHandle(fd));
121 } 125 }
122 126
123 127
124 bool File::Exists(const char* name) { 128 bool File::Exists(const char* name) {
125 struct stat st; 129 struct stat st;
126 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 130 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
127 return S_ISREG(st.st_mode); // Deal with symlinks? 131 return S_ISREG(st.st_mode); // Deal with symlinks?
128 } else { 132 } else {
129 return false; 133 return false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 177
174 178
175 const char* File::PathSeparator() { 179 const char* File::PathSeparator() {
176 return "/"; 180 return "/";
177 } 181 }
178 182
179 183
180 const char* File::StringEscapedPathSeparator() { 184 const char* File::StringEscapedPathSeparator() {
181 return "/"; 185 return "/";
182 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698