mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
add path_prepend_xxx
This commit is contained in:
parent
ea521291e6
commit
d77e905ea4
@ -1,5 +1,9 @@
|
||||
# 最新动态
|
||||
|
||||
2023/09/25
|
||||
* 增加函数path\_prepend\_temp\_path
|
||||
* 增加函数path\_prepend\_user\_storage\_path
|
||||
|
||||
2023/09/24
|
||||
* 增加函数tk\_iostream\_tcp\_create\_client
|
||||
* 增加函数hash\_table\_size
|
||||
|
@ -346,6 +346,26 @@ const char* path_prepend_app_root(char full_path[MAX_PATH + 1], const char* path
|
||||
return full_path;
|
||||
}
|
||||
|
||||
const char* path_prepend_temp_path(char full_path[MAX_PATH + 1], const char* path) {
|
||||
char temp_path[MAX_PATH + 1] = {0};
|
||||
return_value_if_fail(path != NULL, NULL);
|
||||
return_value_if_fail(fs_get_temp_path(os_fs(), temp_path) == RET_OK, NULL);
|
||||
|
||||
path_build(full_path, MAX_PATH, temp_path, path, NULL);
|
||||
|
||||
return full_path;
|
||||
}
|
||||
|
||||
const char* path_prepend_user_storage_path(char full_path[MAX_PATH + 1], const char* path) {
|
||||
char user_storage_path[MAX_PATH + 1] = {0};
|
||||
return_value_if_fail(path != NULL, NULL);
|
||||
return_value_if_fail(fs_get_user_storage_path(os_fs(), user_storage_path) == RET_OK, NULL);
|
||||
|
||||
path_build(full_path, MAX_PATH, user_storage_path, path, NULL);
|
||||
|
||||
return full_path;
|
||||
}
|
||||
|
||||
ret_t path_abs_normalize(const char* filename, char* result, int32_t size) {
|
||||
char path[MAX_PATH + 1];
|
||||
return_value_if_fail(filename != NULL && result != NULL && size > 0, RET_BAD_PARAMS);
|
||||
|
@ -257,6 +257,26 @@ ret_t path_remove_last_slash(char* path);
|
||||
*/
|
||||
const char* path_prepend_app_root(char full_path[MAX_PATH + 1], const char* path);
|
||||
|
||||
/**
|
||||
* @method path_prepend_temp_path
|
||||
* 将前面路径加上临时文件目录。
|
||||
* @param {char*} full_path 用于返回完整路径。
|
||||
* @param {const char*} path 路径。
|
||||
*
|
||||
* @return {const char*} 返回完整路径。
|
||||
*/
|
||||
const char* path_prepend_temp_path(char full_path[MAX_PATH + 1], const char* path);
|
||||
|
||||
/**
|
||||
* @method path_prepend_user_storage_path
|
||||
* 将前面路径加上用户目录。
|
||||
* @param {char*} full_path 用于返回完整路径。
|
||||
* @param {const char*} path 路径。
|
||||
*
|
||||
* @return {const char*} 返回完整路径。
|
||||
*/
|
||||
const char* path_prepend_user_storage_path(char full_path[MAX_PATH + 1], const char* path);
|
||||
|
||||
/**
|
||||
* @method path_abs_normalize
|
||||
* 将相对路径转换为绝对路径并规范路径字符形式。
|
||||
|
@ -270,6 +270,21 @@ TEST(Path, path_prepend_app_root) {
|
||||
char result[MAX_PATH + 1] = {0};
|
||||
ASSERT_EQ(path_prepend_app_root(result, "bin"), result);
|
||||
ASSERT_EQ(path_exist(result), TRUE);
|
||||
log_debug("%s\n", result);
|
||||
}
|
||||
|
||||
TEST(Path, path_prepend_temp_path) {
|
||||
char result[MAX_PATH + 1] = {0};
|
||||
ASSERT_EQ(path_prepend_temp_path(result, "test.txt"), result);
|
||||
ASSERT_NE(strstr(result, "test.txt"), (char*)NULL);
|
||||
log_debug("%s\n", result);
|
||||
}
|
||||
|
||||
TEST(Path, path_prepend_user_storage_path) {
|
||||
char result[MAX_PATH + 1] = {0};
|
||||
ASSERT_EQ(path_prepend_user_storage_path(result, "test.txt"), result);
|
||||
ASSERT_NE(strstr(result, "test.txt"), (char*)NULL);
|
||||
log_debug("%s\n", result);
|
||||
}
|
||||
|
||||
TEST(Path, abs_normalize) {
|
||||
|
Loading…
Reference in New Issue
Block a user