improve system_info

This commit is contained in:
lixianjing 2021-11-08 17:52:49 +08:00
parent f3ea5d7799
commit 66d4ccd0b0
2 changed files with 25 additions and 7 deletions

View File

@ -2,6 +2,7 @@
2021/11/08
* 优化OpenGL每次全屏clear的逻辑感谢智明提供补丁
* 增加查询上一级目录的资源逻辑(感谢智明提供补丁)。
* fscript 中变量名以英文点开头时报错并将其直接当做字符串处理(感谢雨欣提供补丁)
* 修复tab\_button\_group由小变大后无法复原子控 件的位置的问题(感谢智明提供补丁)。

View File

@ -88,17 +88,19 @@ static ret_t system_info_normalize_app_root_try_default(system_info_t* info,
return RET_FAIL;
}
static ret_t system_info_normalize_app_root_try_path(system_info_t* info, char* path) {
static ret_t system_info_normalize_app_root_try_path(system_info_t* info, char* path, bool_t ignore_bin) {
char* last = NULL;
char app_root[MAX_PATH + 1] = {0};
log_debug("try %s\n", path);
if (!ignore_bin) {
last = strrchr(path, TK_PATH_SEP);
if (last != NULL) {
if (tk_str_eq(last + 1, "bin")) {
*last = '\0';
}
}
}
if (!app_root_is_valid(path)) {
path_build(app_root, MAX_PATH, path, "res", NULL);
@ -123,7 +125,7 @@ static ret_t system_info_normalize_app_root_try_cwd(system_info_t* info) {
char path[MAX_PATH + 1] = {0};
return_value_if_fail(path_cwd(path) == RET_OK, RET_FAIL);
return system_info_normalize_app_root_try_path(info, path);
return system_info_normalize_app_root_try_path(info, path, FALSE);
}
static ret_t system_info_normalize_app_root_try_exe(system_info_t* info) {
@ -136,7 +138,20 @@ static ret_t system_info_normalize_app_root_try_exe(system_info_t* info) {
*last = '\0';
}
return system_info_normalize_app_root_try_path(info, path);
return system_info_normalize_app_root_try_path(info, path, FALSE);
}
static ret_t system_info_normalize_app_root_try_parent_dir(system_info_t* info) {
char* last = NULL;
char path[MAX_PATH + 1] = {0};
return_value_if_fail(path_cwd(path) == RET_OK, RET_FAIL);
last = strrchr(path, TK_PATH_SEP);
if (last != NULL) {
*last = '\0';
}
return system_info_normalize_app_root_try_path(info, path, TRUE);
}
static ret_t system_info_normalize_app_root(system_info_t* info, const char* app_root_default) {
@ -146,6 +161,8 @@ static ret_t system_info_normalize_app_root(system_info_t* info, const char* app
return RET_OK;
} else if (system_info_normalize_app_root_try_exe(info) == RET_OK) {
return RET_OK;
} else if (system_info_normalize_app_root_try_parent_dir(info) == RET_OK) {
return RET_OK;
} else {
system_info_set_app_root(info, "");
}