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

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

Issue 9034005: Change the behavior of open on files to not truncate by default (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comment.s Created 8 years, 11 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_win.cc ('k') | runtime/bin/main.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Generate a snapshot file after loading all the scripts specified on the 5 // Generate a snapshot file after loading all the scripts specified on the
6 // command line. 6 // command line.
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 i += 1; 98 i += 1;
99 } else { 99 } else {
100 *script_name = NULL; 100 *script_name = NULL;
101 } 101 }
102 102
103 return 0; 103 return 0;
104 } 104 }
105 105
106 106
107 static void WriteSnapshotFile(const uint8_t* buffer, const intptr_t size) { 107 static void WriteSnapshotFile(const uint8_t* buffer, const intptr_t size) {
108 const bool kWritable = true; 108 File* file = File::Open(snapshot_filename, File::kWriteTruncate);
109 File* file = File::Open(snapshot_filename, kWritable);
110 ASSERT(file != NULL); 109 ASSERT(file != NULL);
111 for (intptr_t i = 0; i < size; i++) { 110 for (intptr_t i = 0; i < size; i++) {
112 file->WriteByte(buffer[i]); 111 file->WriteByte(buffer[i]);
113 } 112 }
114 delete file; 113 delete file;
115 } 114 }
116 115
117 116
118 static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag, 117 static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
119 Dart_Handle library, 118 Dart_Handle library,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 exit(255); 267 exit(255);
269 } 268 }
270 // Now write the snapshot out to specified file and exit. 269 // Now write the snapshot out to specified file and exit.
271 WriteSnapshotFile(buffer, size); 270 WriteSnapshotFile(buffer, size);
272 Dart_ExitScope(); 271 Dart_ExitScope();
273 272
274 // Shutdown the isolate. 273 // Shutdown the isolate.
275 Dart_ShutdownIsolate(); 274 Dart_ShutdownIsolate();
276 return 0; 275 return 0;
277 } 276 }
OLDNEW
« no previous file with comments | « runtime/bin/file_win.cc ('k') | runtime/bin/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698