| OLD | NEW |
| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
| 10 #include "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 if ((snapshot_directory != NULL) && (strlen(snapshot_directory) > 0)) { | 1053 if ((snapshot_directory != NULL) && (strlen(snapshot_directory) > 0)) { |
| 1054 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename); | 1054 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename); |
| 1055 concat = new char[len + 1]; | 1055 concat = new char[len + 1]; |
| 1056 snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename); | 1056 snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename); |
| 1057 qualified_filename = concat; | 1057 qualified_filename = concat; |
| 1058 } else { | 1058 } else { |
| 1059 qualified_filename = filename; | 1059 qualified_filename = filename; |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 File* file = File::Open(qualified_filename, File::kWriteTruncate); | 1062 File* file = File::Open(qualified_filename, File::kWriteTruncate); |
| 1063 ASSERT(file != NULL); | 1063 if (file == NULL) { |
| 1064 ErrorExit(kErrorExitCode, |
| 1065 "Unable to open file %s for writing snapshot\n", |
| 1066 qualified_filename); |
| 1067 } |
| 1064 | 1068 |
| 1065 if (write_magic_number) { | 1069 if (write_magic_number) { |
| 1066 // Write the magic number to indicate file is a script snapshot. | 1070 // Write the magic number to indicate file is a script snapshot. |
| 1067 DartUtils::WriteMagicNumber(file); | 1071 DartUtils::WriteMagicNumber(file); |
| 1068 } | 1072 } |
| 1069 | 1073 |
| 1070 if (!file->WriteFully(buffer, size)) { | 1074 if (!file->WriteFully(buffer, size)) { |
| 1071 ErrorExit(kErrorExitCode, | 1075 ErrorExit(kErrorExitCode, |
| 1072 "Unable to open file %s for writing snapshot\n", | 1076 "Unable to write file %s for writing snapshot\n", |
| 1073 qualified_filename); | 1077 qualified_filename); |
| 1074 } | 1078 } |
| 1075 file->Release(); | 1079 file->Release(); |
| 1076 if (concat != NULL) { | 1080 if (concat != NULL) { |
| 1077 delete concat; | 1081 delete concat; |
| 1078 } | 1082 } |
| 1079 } | 1083 } |
| 1080 | 1084 |
| 1081 | 1085 |
| 1082 static void ReadSnapshotFile(const char* snapshot_directory, | 1086 static void ReadSnapshotFile(const char* snapshot_directory, |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1745 Platform::Exit(Process::GlobalExitCode()); | 1749 Platform::Exit(Process::GlobalExitCode()); |
| 1746 } | 1750 } |
| 1747 | 1751 |
| 1748 } // namespace bin | 1752 } // namespace bin |
| 1749 } // namespace dart | 1753 } // namespace dart |
| 1750 | 1754 |
| 1751 int main(int argc, char** argv) { | 1755 int main(int argc, char** argv) { |
| 1752 dart::bin::main(argc, argv); | 1756 dart::bin::main(argc, argv); |
| 1753 UNREACHABLE(); | 1757 UNREACHABLE(); |
| 1754 } | 1758 } |
| OLD | NEW |