File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 8
8
9
9
#include < bin/dartutils.h>
10
10
#include < bin/dfe.h>
11
+ #include < bin/file.h>
11
12
#include < bin/gzip.h>
12
13
#include < bin/loader.h>
13
14
#include < bin/isolate_data.h>
@@ -30,6 +31,21 @@ extern const uint8_t* observatory_assets_archive;
30
31
} // namespace bin
31
32
} // namespace dart
32
33
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
+
33
49
Dart_Handle GetVMServiceAssetsArchiveCallback () {
34
50
uint8_t * decompressed = NULL ;
35
51
intptr_t decompressed_len = 0 ;
@@ -161,6 +177,8 @@ bool DartDll_Initialize(const DartDllConfig& config) {
161
177
std::cout << " Dart initialized, error was: "
162
178
<< (initError != nullptr ? initError : " null" ) << std::endl;
163
179
180
+ Dart_SetFileModifiedCallback (&FileModifiedCallback);
181
+
164
182
return true ;
165
183
}
166
184
Original file line number Diff line number Diff line change @@ -69,6 +69,9 @@ Dart_Handle SetupCoreLibraries(Dart_Isolate isolate,
69
69
}
70
70
}
71
71
72
+ result = Dart_SetEnvironmentCallback (DartUtils::EnvironmentCallback);
73
+ if (Dart_IsError (result)) return result;
74
+
72
75
// Setup the native resolver as the snapshot does not carry it.
73
76
Builtin::SetNativeResolver (Builtin::kBuiltinLibrary );
74
77
Builtin::SetNativeResolver (Builtin::kIOLibrary );
@@ -160,7 +163,11 @@ Dart_Isolate CreateVmServiceIsolate(const char* script_uri,
160
163
return nullptr ;
161
164
}
162
165
163
- // TODO -- Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback)
166
+ Dart_EnterIsolate (isolate);
167
+ Dart_EnterScope ();
168
+ Dart_SetEnvironmentCallback (DartUtils::EnvironmentCallback);
169
+ Dart_ExitScope ();
170
+ Dart_ExitIsolate ();
164
171
165
172
return isolate;
166
173
}
You can’t perform that action at this time.
0 commit comments