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

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
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (position < 0) {
123 return NULL;
124 }
125 }
120 return new File(name, new FileHandle(fd)); 126 return new File(name, new FileHandle(fd));
121 } 127 }
122 128
123 129
124 bool File::Exists(const char* name) { 130 bool File::Exists(const char* name) {
125 struct stat st; 131 struct stat st;
126 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 132 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
127 return S_ISREG(st.st_mode); // Deal with symlinks? 133 return S_ISREG(st.st_mode); // Deal with symlinks?
128 } else { 134 } else {
129 return false; 135 return false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 179
174 180
175 const char* File::PathSeparator() { 181 const char* File::PathSeparator() {
176 return "/"; 182 return "/";
177 } 183 }
178 184
179 185
180 const char* File::StringEscapedPathSeparator() { 186 const char* File::StringEscapedPathSeparator() {
181 return "/"; 187 return "/";
182 } 188 }
OLDNEW
« 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