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

Side by Side Diff: runtime/bin/file_linux.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_impl.dart ('k') | runtime/bin/file_macos.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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if ((mode & kWrite) != 0) { 109 if ((mode & kWrite) != 0) {
110 flags = (O_RDWR | O_CREAT); 110 flags = (O_RDWR | O_CREAT);
111 } 111 }
112 if ((mode & kTruncate) != 0) { 112 if ((mode & kTruncate) != 0) {
113 flags = flags | O_TRUNC; 113 flags = flags | O_TRUNC;
114 } 114 }
115 int fd = TEMP_FAILURE_RETRY(open(name, flags, 0666)); 115 int fd = TEMP_FAILURE_RETRY(open(name, flags, 0666));
116 if (fd < 0) { 116 if (fd < 0) {
117 return NULL; 117 return NULL;
118 } 118 }
119 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) {
120 int position = TEMP_FAILURE_RETRY(lseek(fd, 0, SEEK_END));
121 if (position < 0) {
122 return NULL;
123 }
124 }
119 return new File(name, new FileHandle(fd)); 125 return new File(name, new FileHandle(fd));
120 } 126 }
121 127
122 128
123 bool File::Exists(const char* name) { 129 bool File::Exists(const char* name) {
124 struct stat st; 130 struct stat st;
125 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 131 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
126 return S_ISREG(st.st_mode); // Deal with symlinks? 132 return S_ISREG(st.st_mode); // Deal with symlinks?
127 } else { 133 } else {
128 return false; 134 return false;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 172
167 173
168 const char* File::PathSeparator() { 174 const char* File::PathSeparator() {
169 return "/"; 175 return "/";
170 } 176 }
171 177
172 178
173 const char* File::StringEscapedPathSeparator() { 179 const char* File::StringEscapedPathSeparator() {
174 return "/"; 180 return "/";
175 } 181 }
OLDNEW
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/bin/file_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698