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

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
« no previous file with comments | « runtime/bin/file_macos.cc ('k') | tests/standalone/src/FileTest.dart » ('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 <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 if (position < 0) {
119 return NULL;
120 }
121 }
116 return new File(name, new FileHandle(fd)); 122 return new File(name, new FileHandle(fd));
117 } 123 }
118 124
119 125
120 bool File::Exists(const char* name) { 126 bool File::Exists(const char* name) {
121 struct stat st; 127 struct stat st;
122 if (stat(name, &st) == 0) { 128 if (stat(name, &st) == 0) {
123 return ((st.st_mode & S_IFMT) == S_IFREG); 129 return ((st.st_mode & S_IFMT) == S_IFREG);
124 } else { 130 } else {
125 return false; 131 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 170
165 171
166 const char* File::PathSeparator() { 172 const char* File::PathSeparator() {
167 return "\\"; 173 return "\\";
168 } 174 }
169 175
170 176
171 const char* File::StringEscapedPathSeparator() { 177 const char* File::StringEscapedPathSeparator() {
172 return "\\\\"; 178 return "\\\\";
173 } 179 }
OLDNEW
« no previous file with comments | « runtime/bin/file_macos.cc ('k') | tests/standalone/src/FileTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698