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

Side by Side Diff: runtime/bin/file_win.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 <fcntl.h> 7 #include <fcntl.h>
8 #include <io.h> 8 #include <io.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if ((mode & kWrite) != 0) { 106 if ((mode & kWrite) != 0) {
107 flags = (O_RDWR | O_CREAT | O_BINARY); 107 flags = (O_RDWR | O_CREAT | O_BINARY);
108 } 108 }
109 if ((mode & kTruncate) != 0) { 109 if ((mode & kTruncate) != 0) {
110 flags = flags | O_TRUNC; 110 flags = flags | O_TRUNC;
111 } 111 }
112 int fd = open(name, flags, 0666); 112 int fd = open(name, flags, 0666);
113 if (fd < 0) { 113 if (fd < 0) {
114 return NULL; 114 return NULL;
115 } 115 }
116 if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) {
117 int position = lseek(fd, 0, SEEK_END);
118 ASSERT(position >= 0);
119 }
116 return new File(name, new FileHandle(fd)); 120 return new File(name, new FileHandle(fd));
117 } 121 }
118 122
119 123
120 bool File::Exists(const char* name) { 124 bool File::Exists(const char* name) {
121 struct stat st; 125 struct stat st;
122 if (stat(name, &st) == 0) { 126 if (stat(name, &st) == 0) {
123 return ((st.st_mode & S_IFMT) == S_IFREG); 127 return ((st.st_mode & S_IFMT) == S_IFREG);
124 } else { 128 } else {
125 return false; 129 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 168
165 169
166 const char* File::PathSeparator() { 170 const char* File::PathSeparator() {
167 return "\\"; 171 return "\\";
168 } 172 }
169 173
170 174
171 const char* File::StringEscapedPathSeparator() { 175 const char* File::StringEscapedPathSeparator() {
172 return "\\\\"; 176 return "\\\\";
173 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698