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 <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 375 } |
376 | 376 |
377 return 0; | 377 return 0; |
378 } | 378 } |
379 | 379 |
380 | 380 |
381 static void WriteSnapshotFile(const char* filename, | 381 static void WriteSnapshotFile(const char* filename, |
382 const uint8_t* buffer, | 382 const uint8_t* buffer, |
383 const intptr_t size) { | 383 const intptr_t size) { |
384 File* file = File::Open(filename, File::kWriteTruncate); | 384 File* file = File::Open(filename, File::kWriteTruncate); |
385 ASSERT(file != NULL); | 385 if (file == NULL) { |
| 386 Log::PrintErr("Error: Unable to write snapshot file: %s\n\n", filename); |
| 387 Dart_ExitScope(); |
| 388 Dart_ShutdownIsolate(); |
| 389 exit(kErrorExitCode); |
| 390 } |
386 if (!file->WriteFully(buffer, size)) { | 391 if (!file->WriteFully(buffer, size)) { |
387 Log::PrintErr("Error: Failed to write snapshot file.\n\n"); | 392 Log::PrintErr("Error: Failed to write snapshot file.\n\n"); |
388 } | 393 } |
389 file->Release(); | 394 file->Release(); |
390 } | 395 } |
391 | 396 |
392 | 397 |
393 class UriResolverIsolateScope { | 398 class UriResolverIsolateScope { |
394 public: | 399 public: |
395 UriResolverIsolateScope() { | 400 UriResolverIsolateScope() { |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 EventHandler::Stop(); | 1370 EventHandler::Stop(); |
1366 return 0; | 1371 return 0; |
1367 } | 1372 } |
1368 | 1373 |
1369 } // namespace bin | 1374 } // namespace bin |
1370 } // namespace dart | 1375 } // namespace dart |
1371 | 1376 |
1372 int main(int argc, char** argv) { | 1377 int main(int argc, char** argv) { |
1373 return dart::bin::main(argc, argv); | 1378 return dart::bin::main(argc, argv); |
1374 } | 1379 } |
OLD | NEW |