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

Unified Diff: runtime/bin/main.cc

Issue 499743002: Delays creating a snapshot file until after the snapshot is created. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: moved tests to standalone/io Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/io/snapshot_fail_script.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
===================================================================
--- runtime/bin/main.cc (revision 39997)
+++ runtime/bin/main.cc (working copy)
@@ -34,7 +34,7 @@
// Global state that stores a pointer to the application script snapshot.
static bool generate_script_snapshot = false;
-static File* snapshot_file = NULL;
+static const char* snapshot_filename = NULL;
// Global state that indicates whether there is a debug breakpoint.
@@ -274,12 +274,7 @@
" dart\n");
return false;
}
- snapshot_file = File::Open(filename, File::kWriteTruncate);
- if (snapshot_file == NULL) {
- Log::PrintErr("Unable to open file %s for writing the snapshot\n",
- filename);
- return false;
- }
+ snapshot_filename = filename;
generate_script_snapshot = true;
return true;
}
@@ -1073,6 +1068,14 @@
result = Dart_CreateScriptSnapshot(&buffer, &size);
DartExitOnError(result);
+ // Open the snapshot file.
+ File* snapshot_file = File::Open(snapshot_filename, File::kWriteTruncate);
+ if (snapshot_file == NULL) {
+ ErrorExit(kErrorExitCode,
+ "Unable to open file %s for writing the snapshot\n",
+ snapshot_filename);
+ }
+
// Write the magic number to indicate file is a script snapshot.
DartUtils::WriteMagicNumber(snapshot_file);
@@ -1080,6 +1083,7 @@
bool bytes_written = snapshot_file->WriteFully(buffer, size);
ASSERT(bytes_written);
delete snapshot_file;
+ snapshot_file = NULL;
} else {
// Lookup the library of the root script.
Dart_Handle root_lib = Dart_RootLibrary();
« no previous file with comments | « no previous file | tests/standalone/io/snapshot_fail_script.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698