| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return -1; | 136 return -1; |
| 137 } | 137 } |
| 138 | 138 |
| 139 return 0; | 139 return 0; |
| 140 } | 140 } |
| 141 | 141 |
| 142 | 142 |
| 143 static void WriteSnapshotFile(const uint8_t* buffer, const intptr_t size) { | 143 static void WriteSnapshotFile(const uint8_t* buffer, const intptr_t size) { |
| 144 File* file = File::Open(snapshot_filename, File::kWriteTruncate); | 144 File* file = File::Open(snapshot_filename, File::kWriteTruncate); |
| 145 ASSERT(file != NULL); | 145 ASSERT(file != NULL); |
| 146 for (intptr_t i = 0; i < size; i++) { | 146 if (!file->WriteFully(buffer, size)) { |
| 147 file->WriteByte(buffer[i]); | 147 Log::PrintErr("Error: Failed to write full snapshot.\n\n"); |
| 148 } | 148 } |
| 149 delete file; | 149 delete file; |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 class UriResolverIsolateScope { | 153 class UriResolverIsolateScope { |
| 154 public: | 154 public: |
| 155 UriResolverIsolateScope() { | 155 UriResolverIsolateScope() { |
| 156 ASSERT(isolate != NULL); | 156 ASSERT(isolate != NULL); |
| 157 snapshotted_isolate_ = Dart_CurrentIsolate(); | 157 snapshotted_isolate_ = Dart_CurrentIsolate(); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 } | 565 } |
| 566 return 0; | 566 return 0; |
| 567 } | 567 } |
| 568 | 568 |
| 569 } // namespace bin | 569 } // namespace bin |
| 570 } // namespace dart | 570 } // namespace dart |
| 571 | 571 |
| 572 int main(int argc, char** argv) { | 572 int main(int argc, char** argv) { |
| 573 return dart::bin::main(argc, argv); | 573 return dart::bin::main(argc, argv); |
| 574 } | 574 } |
| OLD | NEW |