File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 88
99#include < bin/dartutils.h>
1010#include < bin/dfe.h>
11+ #include < bin/file.h>
1112#include < bin/gzip.h>
1213#include < bin/loader.h>
1314#include < bin/isolate_data.h>
@@ -30,6 +31,21 @@ extern const uint8_t* observatory_assets_archive;
3031} // namespace bin
3132} // namespace dart
3233
34+ static bool FileModifiedCallback (const char * url, int64_t since) {
35+ auto path = File::UriToPath (url);
36+ if (path == nullptr ) {
37+ // If it isn't a file on local disk, we don't know if it has been
38+ // modified.
39+ return true ;
40+ }
41+ int64_t data[File::kStatSize ];
42+ File::Stat (nullptr , path.get (), data);
43+ if (data[File::kType ] == File::kDoesNotExist ) {
44+ return true ;
45+ }
46+ return data[File::kModifiedTime ] > since;
47+ }
48+
3349Dart_Handle GetVMServiceAssetsArchiveCallback () {
3450 uint8_t * decompressed = NULL ;
3551 intptr_t decompressed_len = 0 ;
@@ -161,6 +177,8 @@ bool DartDll_Initialize(const DartDllConfig& config) {
161177 std::cout << " Dart initialized, error was: "
162178 << (initError != nullptr ? initError : " null" ) << std::endl;
163179
180+ Dart_SetFileModifiedCallback (&FileModifiedCallback);
181+
164182 return true ;
165183}
166184
Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ Dart_Handle SetupCoreLibraries(Dart_Isolate isolate,
6969 }
7070 }
7171
72+ result = Dart_SetEnvironmentCallback (DartUtils::EnvironmentCallback);
73+ if (Dart_IsError (result)) return result;
74+
7275 // Setup the native resolver as the snapshot does not carry it.
7376 Builtin::SetNativeResolver (Builtin::kBuiltinLibrary );
7477 Builtin::SetNativeResolver (Builtin::kIOLibrary );
@@ -160,7 +163,11 @@ Dart_Isolate CreateVmServiceIsolate(const char* script_uri,
160163 return nullptr ;
161164 }
162165
163- // TODO -- Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback)
166+ Dart_EnterIsolate (isolate);
167+ Dart_EnterScope ();
168+ Dart_SetEnvironmentCallback (DartUtils::EnvironmentCallback);
169+ Dart_ExitScope ();
170+ Dart_ExitIsolate ();
164171
165172 return isolate;
166173}
You can’t perform that action at this time.
0 commit comments