@@ -447,25 +447,41 @@ EmbeddedAssemblies::gather_bundled_assemblies_from_apk (const char* apk, monodro
447
447
}
448
448
449
449
#if defined (DEBUG) || !defined (ANDROID)
450
+ bool
451
+ EmbeddedAssemblies::typemap_load_index (const char *index_path)
452
+ {
453
+ return false ;
454
+ }
455
+
450
456
void
451
457
EmbeddedAssemblies::try_load_typemaps_from_directory (const char *path)
452
458
{
453
459
// read the entire typemap file into a string
454
460
// process the string using the add_type_mapping
455
- char * dir_path = utils.path_combine (path, " typemaps" );
456
- if (dir_path == nullptr || !utils. directory_exists (dir_path)) {
457
- log_warn (LOG_DEFAULT, " directory does not exist: `%s` " , dir_path);
458
- free ( dir_path);
461
+ simple_pointer_guard< char []> dir_path ( utils.path_combine (path, " typemaps" ) );
462
+
463
+ if (!utils. directory_exists ( dir_path)) {
464
+ log_warn (LOG_DEFAULT, " directory does not exist: `%s` " , dir_path. get () );
459
465
return ;
460
466
}
461
467
462
468
monodroid_dir_t *dir;
463
469
if ((dir = utils.monodroid_opendir (dir_path)) == nullptr ) {
464
- log_warn (LOG_DEFAULT, " could not open directory: `%s`" , dir_path);
465
- free (dir_path);
470
+ log_warn (LOG_DEFAULT, " could not open directory: `%s`" , dir_path.get ());
466
471
return ;
467
472
}
468
473
474
+ simple_pointer_guard<char []> index_path (utils.path_combine (dir_path, " typemap.index" ));
475
+ if (!utils.file_exists (index_path)) {
476
+ log_fatal (LOG_ASSEMBLY, " TypeMap data index file not found: %s" , index_path.get ());
477
+ exit (FATAL_EXIT_NO_ASSEMBLIES); // TODO: use a new error code here
478
+ }
479
+
480
+ if (!typemap_load_index (index_path)) {
481
+ log_fatal (LOG_ASSEMBLY, " Unable to load TypeMap data index from '%s'" , index_path.get ());
482
+ exit (FATAL_EXIT_NO_ASSEMBLIES); // TODO: use a new error code here
483
+ }
484
+
469
485
monodroid_dirent_t *e;
470
486
while ((e = androidSystem.readdir (dir)) != nullptr ) {
471
487
#if WINDOWS
@@ -489,8 +505,6 @@ EmbeddedAssemblies::try_load_typemaps_from_directory (const char *path)
489
505
}
490
506
}
491
507
utils.monodroid_closedir (dir);
492
- free (dir_path);
493
- return ;
494
508
}
495
509
#endif
496
510
0 commit comments