Merge pull request #16002 from bruvzg/mono_loading_form_res

[Mono] Allow loading assemblies (including mscorlib) from resources.
This commit is contained in:
Rémi Verschelde 2018-02-01 14:36:05 +01:00 committed by GitHub
commit 906ac2fc9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -479,6 +479,9 @@ void FileAccess::store_double(double p_dest) {
uint64_t FileAccess::get_modified_time(const String &p_file) {
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file))
return 0;
FileAccess *fa = create_for_path(p_file);
ERR_FAIL_COND_V(!fa, 0);

View File

@ -116,6 +116,37 @@ MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **asse
}
}
String name = mono_assembly_name_get_name(aname);
bool has_extension = name.ends_with(".dll");
if (has_extension ? name == "mscorlib.dll" : name == "mscorlib") {
GDMonoAssembly **stored_assembly = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name);
if (stored_assembly) return (*stored_assembly)->get_assembly();
String path;
MonoAssembly *res = NULL;
for (int i = 0; i < search_dirs.size(); i++) {
const String &search_dir = search_dirs[i];
if (has_extension) {
path = search_dir.plus_file(name);
if (FileAccess::exists(path)) {
res = _load_assembly_from(name.get_basename(), path);
break;
}
} else {
path = search_dir.plus_file(name + ".dll");
if (FileAccess::exists(path)) {
res = _load_assembly_from(name, path);
break;
}
}
}
if (res) return res;
}
return NULL;
}