1616#include  < shlwapi.h> 
1717#endif 
1818
19- #include  " globals.hh" 
19+ #include  < mono/metadata/object.h> 
20+ 
2021#include  " android-system.hh" 
22+ #include  " debug.hh" 
2123#include  " monodroid.h" 
2224#include  " monodroid-glue-internal.hh" 
2325#include  " jni-wrappers.hh" 
@@ -163,7 +165,7 @@ AndroidSystem::_monodroid__system_property_get (const char *name, char *sp_value
163165	if  (!name || !sp_value)
164166		return  -1 ;
165167
166- 	char  *env_name = utils. monodroid_strdup_printf  (" __XA_%s" 
168+ 	char  *env_name = Util:: monodroid_strdup_printf" __XA_%s" 
167169	monodroid_strreplace  (env_name, ' .' ' _' 
168170	char  *env_value = getenv  (env_name);
169171	free  (env_name);
@@ -243,7 +245,7 @@ AndroidSystem::monodroid_get_system_property_impl (const char *name, dynamic_loc
243245int 
244246AndroidSystem::monodroid_get_system_property  (const  char  *name, gsl::owner<char **> value) noexcept 
245247{
246- 	if  (value)
248+ 	if  (value !=  nullptr )
247249		*value = nullptr ;
248250
249251	dynamic_local_string<PROPERTY_VALUE_BUFFER_LEN> sp_value;
@@ -259,7 +261,7 @@ AndroidSystem::monodroid_get_system_property (const char *name, gsl::owner<char*
259261		}
260262	}
261263
262- 	if  (len >= 0  && value) {
264+ 	if  (len >= 0  && value !=  nullptr ) {
263265		auto  alloc_size = ADD_WITH_OVERFLOW_CHECK  (size_t , static_cast <size_t >(len), 1 );
264266		*value = new  char  [alloc_size];
265267		if  (*value == nullptr )
@@ -285,7 +287,7 @@ AndroidSystem::_monodroid_get_system_property_from_file (const char *path, char
285287	if  (value != nullptr )
286288		*value = nullptr ;
287289
288- 	FILE* fp = utils. monodroid_fopen  (path, " r" 
290+ 	FILE* fp = Util:: monodroid_fopen" r" 
289291	if  (fp == nullptr )
290292		return  0 ;
291293
@@ -325,7 +327,7 @@ AndroidSystem::monodroid_get_system_property_from_overrides ([[maybe_unused]] co
325327			continue ;
326328		}
327329
328- 		std::unique_ptr<char []> override_file {utils. path_combine  (dir, name)};
330+ 		std::unique_ptr<char []> override_file {Util:: path_combine
329331		log_info  (LOG_DEFAULT, " Trying to get property from %s" get  ());
330332
331333		size_t  result = _monodroid_get_system_property_from_file  (override_file.get  (), value);
@@ -350,13 +352,13 @@ AndroidSystem::create_update_dir (char *override_dir) noexcept
350352	 * However, if any logging is enabled (which should _not_ happen with 
351353	 * pre-loaded apps!), we need the .__override__ directory... 
352354	 */  
353- 	if  (log_categories == 0  && monodroid_system_property_exists  (Debug::DEBUG_MONO_PROFILE_PROPERTY) ==  0 ) {
355+ 	if  (log_categories == 0  && monodroid_system_property_exists  (Debug::DEBUG_MONO_PROFILE_PROPERTY)) {
354356		return ;
355357	}
356358#endif 
357359
358360	set_override_dir  (0 , override_dir);
359- 	utils. create_public_directory  (override_dir);
361+ 	Util:: create_public_directory
360362	log_warn  (LOG_DEFAULT, " Creating public update directory: `%s`" 
361363}
362364
@@ -367,7 +369,7 @@ AndroidSystem::get_full_dso_path (const char *base_dir, const char *dso_path, dy
367369		return  false ;
368370	}
369371
370- 	if  (base_dir == nullptr  || utils. is_path_rooted  (dso_path)) {
372+ 	if  (base_dir == nullptr  || Util:: is_path_rooted
371373		path.assign_c  (dso_path); //  Absolute path or no base path, can't do much with it
372374		return  true ;
373375	}
@@ -386,14 +388,14 @@ AndroidSystem::load_dso (const char *path, unsigned int dl_flags, bool skip_exis
386388		return  nullptr ;
387389
388390	log_info  (LOG_ASSEMBLY, " Trying to load shared library '%s'" 
389- 	if  (!skip_exists_check && !is_embedded_dso_mode_enabled  () && !utils. file_exists  (path)) {
391+ 	if  (!skip_exists_check && !is_embedded_dso_mode_enabled  () && !Util:: file_exists
390392		log_info  (LOG_ASSEMBLY, " Shared library '%s' not found" 
391393		return  nullptr ;
392394	}
393395
394396	char  *error = nullptr ;
395397	void  *handle = java_interop_lib_load  (path, dl_flags, &error);
396- 	if  (handle == nullptr  && utils. should_log  (LOG_ASSEMBLY))
398+ 	if  (handle == nullptr  && Util:: should_log
397399		log_info_nocheck  (LOG_ASSEMBLY, " Failed to load shared library '%s'. %s" 
398400	java_interop_free  (error);
399401	return  handle;
@@ -438,10 +440,7 @@ AndroidSystem::load_dso_from_any_directories (const char *name, unsigned int dl_
438440bool 
439441AndroidSystem::get_existing_dso_path_on_disk  (const  char  *base_dir, const  char  *dso_name, dynamic_local_string<SENSIBLE_PATH_MAX>& path) noexcept 
440442{
441- 	if  (get_full_dso_path  (base_dir, dso_name, path) && utils.file_exists  (path.get  ()))
442- 		return  true ;
443- 
444- 	return  false ;
443+ 	return  get_full_dso_path  (base_dir, dso_name, path) && Util::file_exists  (path.get  ());
445444}
446445
447446bool 
@@ -474,19 +473,19 @@ AndroidSystem::count_override_assemblies () noexcept
474473	int  c = 0 ;
475474
476475	for  (auto  const  dir_path : override_dirs  ()) {
477- 		if  (dir_path == nullptr  || !utils. directory_exists  (dir_path))
476+ 		if  (dir_path == nullptr  || !Util:: directory_exists
478477			continue ;
479478
480- 		monodroid_dir_t  *dir = utils. monodroid_opendir  (dir_path);
479+ 		monodroid_dir_t  *dir = Util:: monodroid_opendir
481480		if  (dir == nullptr )
482481			continue ;
483482
484483		monodroid_dirent_t  *e = nullptr ;
485484		while  ((e = readdir  (dir)) != nullptr  && e) {
486- 			if  (utils. monodroid_dirent_hasextension  (e, " .dll" 
485+ 			if  (Util:: monodroid_dirent_hasextension" .dll" 
487486				++c;
488487		}
489- 		utils. monodroid_closedir  (dir);
488+ 		Util:: monodroid_closedir
490489	}
491490
492491	return  c;
@@ -565,7 +564,7 @@ AndroidSystem::setup_environment_from_override_file (const char *path) noexcept
565564	using  read_count_type = size_t ;
566565#endif 
567566	monodroid_stat_t  sbuf;
568- 	if  (utils. monodroid_stat  (path, &sbuf) < 0 ) {
567+ 	if  (Util:: monodroid_stat0 ) {
569568		log_warn  (LOG_DEFAULT, " Failed to stat the environment override file %s: %s" strerror  (errno));
570569		return ;
571570	}
@@ -717,8 +716,8 @@ AndroidSystem::setup_environment () noexcept
717716#if  defined (DEBUG) || !defined (ANDROID)
718717	//  TODO: for debug read from file in the override directory named `environment`
719718	for  (const  auto  override_dir : override_dirs  ()) {
720- 		std::unique_ptr<char []> env_override_file {utils. path_combine  (override_dir, OVERRIDE_ENVIRONMENT_FILE_NAME)};
721- 		if  (utils. file_exists  (env_override_file.get  ())) {
719+ 		std::unique_ptr<char []> env_override_file {Util:: path_combine
720+ 		if  (Util:: file_existsget  ())) {
722721			setup_environment_from_override_file  (env_override_file.get  ());
723722		}
724723	}
@@ -783,15 +782,15 @@ AndroidSystem::get_libmonoandroid_directory_path () noexcept
783782
784783	GetModuleFileNameW  (module , module_path, sizeof  (module_path) / sizeof  (module_path[0 ]));
785784	PathRemoveFileSpecW  (module_path);
786- 	libmonoandroid_directory_path = utils. utf16_to_utf8  (module_path);
785+ 	libmonoandroid_directory_path = Util:: utf16_to_utf8
787786	return  libmonoandroid_directory_path;
788787}
789788
790789int 
791790AndroidSystem::setenv  (const  char  *name, const  char  *value, [[maybe_unused]] int  overwrite) noexcept 
792791{
793- 	wchar_t  *wname  = utils. utf8_to_utf16  (name);
794- 	wchar_t  *wvalue = utils. utf8_to_utf16  (value);
792+ 	wchar_t  *wname  = Util:: utf8_to_utf16
793+ 	wchar_t  *wvalue = Util:: utf8_to_utf16
795794
796795	BOOL result = SetEnvironmentVariableW  (wname, wvalue);
797796	free  (wname);
@@ -803,7 +802,7 @@ AndroidSystem::setenv (const char *name, const char *value, [[maybe_unused]] int
803802int 
804803AndroidSystem::symlink  (const  char  *target, const  char  *linkpath) noexcept 
805804{
806- 	return  utils. file_copy  (target, linkpath);
805+ 	return  Util:: file_copy
807806}
808807#else 
809808#endif 
0 commit comments