⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jam_custom.c

📁 java 1.1 gemini 08_16
💻 C
📖 第 1 页 / 共 2 页
字号:
	kal_int32 game_type = GAMETYPE_INVALID_TYPE;

	if (work_info_ptr == j2me_custom_file_info_ptr)
	{
		game_type = GAMETYPE_JAVA_GAME;
	} 
#ifdef __SUPPORT_INFUSIO__
	else if (work_info_ptr == eureka_custom_file_info_ptr)
	{
		game_type = GAMETYPE_INFUSIO_EUREKA;
	} 
#endif /* __SUPPORT_INFUSIO__ */
#ifdef SUPPORT_SURFKITCHEN
	else if (work_info_ptr == surfkitchen_custom_file_info_ptr)
	{
		game_type = GAMETYPE_SURFKITCHEN;
	} 
#endif /* SUPPORT_SURFKITCHEN */
#ifdef SUPPORT_MUSICWAV
	else if (work_info_ptr == musicwav_custom_file_info_ptr)
	{
		game_type = GAMETYPE_MUSICWAV;
	} 
#endif /* SUPPORT_MUSICWAV */
	return game_type;
}

/*****************************************************************************
 * FUNCTION
 *  _jvm_get_initiate_game_type()
 *
 * DESCRIPTION
 *	return the game type of the first running game type.
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
kal_int32
jvm_get_initiate_game_type(void)
{
    return initiate_game_type;
}

/*****************************************************************************
 * FUNCTION
 *  javaFileGenerator
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
extern j2me_custom_resource_info_struct g_jvm_resource_info; /* Dennis Shih */
void 
javaFileGenerator(game_type_enum type, kal_bool force_remove_all)
{
#ifdef __JBLENDIA__
	if(force_remove_all)
	{
		extern void kjava_reset_factory_mode(void);
		kjava_reset_factory_mode();
	}
#else /* __JBLENDIA__ */
	/*----------------------------------------------------------------*/
	/* Local Variables                                                */
	/*----------------------------------------------------------------*/
	kal_int32 attribute;
	kal_uint32 realCount;
	int handle;
	int needToCreate = 1;
	int result;
	kal_char *j2me_release_verno = release_verno();
	kal_uint32 default_file_check_sum;
	kal_char *dir_path = NULL;
	int diskdrive = g_jvm_resource_info.storage_drive; /* Dennis Shih */
	/*----------------------------------------------------------------*/
	/* Code Body                                                      */
	/*----------------------------------------------------------------*/
	/* Check whether the directory exists? */
	dir_path = _jvm_get_dir_path(type);
	kal_wsprintf(WCHARFilename, "%s", dir_path);

	if (!force_remove_all)
	{
		attribute = FS_GetAttributes(WCHARFilename);
		if (attribute > 0)
		{
			/* this directory maybe exists */
			if ((attribute & FS_ATTR_DIR) != FS_ATTR_DIR)
			{
				/* Failed to initialize */
				return;
			} else
			{
				/* need to create the directory and files */
				needToCreate = 0;
			}
		} else
		{
			/* this directory doesn't exist. Create this directory */
			if (FS_CreateDir(WCHARFilename) != FS_NO_ERROR)
			{
				/* Failed to initialize */
				return;
			}
		}
	}
	default_file_check_sum = get_default_game_check_sum(type);

	if (!needToCreate)
	{
		/* Check verno */
		kal_wsprintf(WCHARFilename, "%s\\j2me_verno", dir_path);
		handle = FS_Open(WCHARFilename, FS_READ_ONLY);
		if (handle > 0)
		{
			kal_uint8 *checksum;
			result = FS_Read(handle, (void*)WCHARFilename, strlen(j2me_release_verno) + 1 + 4, &realCount);
			checksum = ((kal_uint8*)WCHARFilename) + strlen(j2me_release_verno) + 1;
			if ((result != FS_NO_ERROR) || strncmp((kal_char*) WCHARFilename, j2me_release_verno, strlen(j2me_release_verno))  ||
				(default_file_check_sum != (checksum[0] << 24) + (checksum[1] << 16) + (checksum[2] << 8) + checksum[3]))
			{
				needToCreate = 1;
			}

			FS_Close(handle);
		} else
		{
			needToCreate = 1;
		}
	}

	if (needToCreate)
	{
		create_default_file(j2me_release_verno, default_file_check_sum, type);
	}

#if SUPPORT_SURFKIT_DRIVE
	/****** Dennis Shih */
	/* Check whether the directory "surfkit" exists? It should under the system drive. */
	kal_wsprintf(WCHARFilename, "%c:\\surfkit", diskdrive);
    if(!force_remove_all)
    {
        attribute = FS_GetAttributes(WCHARFilename);
        if (attribute > 0)
        {
            /* this directory maybe exists */
            if ((attribute & FS_ATTR_DIR) != FS_ATTR_DIR)
            {
                return; /* Failed to initialize */
            }
            else    /* need to create the directory and files */
            {
                needToCreate = 0;
            }
        }
        else
        {
            /* this directory doesn't exist. Create this directory */
            if (FS_CreateDir(WCHARFilename) != FS_NO_ERROR)
            {
                return; /* Failed to initialize */
            }
        }
    }
	/* Dennis Shih ******/
#endif // SUPPORT_SURFKIT_DRIVE
#endif /* __JBLENDIA__ */
    if(force_remove_all)
    {
        jpush_push_restore_factory_setting(type);
    }
}


/*****************************************************************************
 * FUNCTION
 *  javaFileRecovery
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void 
javaFileRecovery(game_type_enum type)
{
	/*----------------------------------------------------------------*/
	/* Local Variables                                                */
	/*----------------------------------------------------------------*/
	kal_int32 attribute;
	kal_uint32 real_size;
	int handle;
	int i, result;
	int normal_file_count;
	const char *normal_file_name;
	const unsigned char *normal_file_data;
	int normal_file_size;
	j2me_custom_file_info_struct *info_ptr = _jvm_get_builtin_file_info(type);
	work_sys_dir_path = _jvm_get_dir_path(type);

	normal_file_count = info_ptr->normal_file_info.normal_file_count;
	/*----------------------------------------------------------------*/
	/* Code Body                                                      */
	/*----------------------------------------------------------------*/
	/* check normal file */
	for (i = 0; i < normal_file_count; i++)
	{
		/* added by Justin to not block low priority task */
		if ((i & 0x3) == 0x3)
		{
			kal_sleep_task(1);
		}

		normal_file_name = info_ptr->normal_file_info.normal_file_name[i];
		normal_file_data = info_ptr->normal_file_info.normal_file_data[i];
		normal_file_size = info_ptr->normal_file_info.normal_file_size[i];

		kal_wsprintf(WCHARFilename, "%s\\%s", work_sys_dir_path, normal_file_name);

		attribute = FS_GetAttributes(WCHARFilename);

		if (attribute < 0)
		{
			/* regenerate file only when file not existed */
			handle = FS_Open(WCHARFilename, FS_READ_WRITE);

			if (handle < 0)
			{
				handle = FS_Open(WCHARFilename, FS_READ_WRITE | FS_CREATE_ALWAYS);
				if (handle < 0)
				{
					handle = FS_Open(WCHARFilename, FS_READ_WRITE | FS_CREATE_ALWAYS | FS_OPEN_SHARED);

					if (handle > 0)
					{
						sprintf(_kvmLogStr, "J2ME Warning: file handle leak - %s", normal_file_name);
						Kputs(_kvmLogStr);
                    }
                    else
					{
						ASSERT(0);
					}
				}
			}

			FS_GetFileSize(handle, &real_size);
			if ((real_size == 0) && (normal_file_size != 0))
			{	/* recovery only when size 0 */
				if ((result = FS_Write(handle, (void*)normal_file_data, normal_file_size, &real_size)) != FS_NO_ERROR)
				{
					sprintf(_kvmLogStr, "J2ME Warning: file recovery write failed - %s, %d", normal_file_name, result);
					Kputs(_kvmLogStr);
				}
				/* added by Justin to not block low priority task */
				kal_sleep_task(1);
			}

			FS_Close(handle);
		}
	}
}


/*****************************************************************************
 * FUNCTION
 *  javaFileRemoveAll
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void 
javaFileRemoveAll(game_type_enum type)
{
	/*----------------------------------------------------------------*/
	/* Local Variables                                                */
	/*----------------------------------------------------------------*/
	int i;
	int normal_file_count;
	const char *normal_file_name;
	j2me_custom_file_info_struct *info_ptr = _jvm_get_builtin_file_info(type);
	work_sys_dir_path = _jvm_get_dir_path(type);

	normal_file_count = info_ptr->normal_file_info.normal_file_count;
	/*----------------------------------------------------------------*/
	/* Code Body                                                      */
	/*----------------------------------------------------------------*/
	/* remove all normal file */
	for (i = 0; i < normal_file_count; i++)
	{
		normal_file_name = info_ptr->normal_file_info.normal_file_name[i];

		kal_wsprintf(WCHARFilename, "%s\\%s", work_sys_dir_path, normal_file_name);
		FS_Delete(WCHARFilename);
		/* added by Justin to not block low priority task */
		if ((i & 0x3) == 0x3)
		{
			kal_sleep_task(1);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -