update services/bundlemgr_lite/src/bundle_util.cpp.

Signed-off-by: shilei91 <shilei91@huawei.com>
This commit is contained in:
shilei91
2022-11-08 09:00:17 +00:00
committed by Gitee
parent bca6e160d9
commit 595d7f9ec6
+12 -2
View File
@@ -49,8 +49,8 @@ const int32_t MAX_JSON_SIZE = 1024 * 64;
const uint32_t MAX_JSON_SIZE = 1024 * 64;
#endif
#ifdef __LITEOS_M__
#ifndef CONFIG_FT_MODE
static void *CJsonBmsMalloc(size_t size)
{
return OhosMalloc(MEM_TYPE_CJSON_LSRAM, size);
@@ -69,7 +69,7 @@ static void OhosBmsCjsonHooksInit(void)
cJSON_InitHooks(&hooks);
}
#endif // CONFIG_FT_MODE
#endif // __LITEOS_M__
/*
* path should not include ".." or "./" or ".\0"
*/
@@ -114,8 +114,10 @@ bool BundleUtil::IsFile(const char *path)
if (ret != 0) {
return false;
}
#ifdef __LITEOS_M__
#ifndef CONFIG_FT_MODE
OhosBmsCjsonHooksInit();
#endif
#endif
int32_t fp = open(path, O_RDONLY, S_IREAD | S_IWRITE);
if (fp >= 0) {
@@ -136,8 +138,10 @@ bool BundleUtil::IsDir(const char *path)
if (ret != 0) {
return false;
}
#ifdef __LITEOS_M__
#ifndef CONFIG_FT_MODE
OhosBmsCjsonHooksInit();
#endif
#endif
if ((buf.st_mode & S_IFDIR) == S_IFDIR) {
return true;
@@ -208,8 +212,10 @@ uint32_t BundleUtil::GetFileSize(const char *filePath)
if (ret != 0) {
return 0;
}
#ifdef __LITEOS_M__
#ifndef CONFIG_FT_MODE
OhosBmsCjsonHooksInit();
#endif
#endif
return fileInfo.st_size;
}
@@ -284,8 +290,10 @@ uint32_t BundleUtil::GetCurrentFolderSize(const char *dirPath, List<char *>* lis
list->PushBack(Utils::Strdup(filePath));
}
}
#ifdef __LITEOS_M__
#ifndef CONFIG_FT_MODE
OhosBmsCjsonHooksInit();
#endif
#endif
closedir(dir);
return fileSize;
@@ -382,8 +390,10 @@ cJSON *BundleUtil::GetJsonStream(const char *path)
#endif
return nullptr;
}
#ifdef __LITEOS_M__
#ifndef CONFIG_FT_MODE
OhosBmsCjsonHooksInit();
#endif
#endif
if (size > MAX_JSON_SIZE) {
#ifdef APP_PLATFORM_WATCHGT