mirror of
https://gitee.com/openharmony/distributedhardware_distributed_hardware_fwk
synced 2024-11-23 15:50:09 +00:00
修改配置文件获取失败
Signed-off-by: litiangang4 <litiangang4@huawei.com>
This commit is contained in:
parent
73b506a596
commit
14caafd39c
@ -71,7 +71,7 @@ namespace DistributedHardware {
|
|||||||
constexpr const char *EVENT_RUN = "EventRun";
|
constexpr const char *EVENT_RUN = "EventRun";
|
||||||
constexpr const char *START_EVENT = "StartEvent";
|
constexpr const char *START_EVENT = "StartEvent";
|
||||||
constexpr const char *COMPONENTSLOAD_PROFILE_PATH =
|
constexpr const char *COMPONENTSLOAD_PROFILE_PATH =
|
||||||
R"(etc/distributedhardware/distributed_hardware_components_cfg.json)";
|
"etc/distributedhardware/distributed_hardware_components_cfg.json";
|
||||||
} // namespace DistributedHardware
|
} // namespace DistributedHardware
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
#endif
|
#endif
|
||||||
|
@ -351,12 +351,13 @@ int32_t ComponentLoader::ParseConfig()
|
|||||||
int32_t ret;
|
int32_t ret;
|
||||||
DHLOGI("ParseConfig start");
|
DHLOGI("ParseConfig start");
|
||||||
char buf[MAX_PATH_LEN] = {0};
|
char buf[MAX_PATH_LEN] = {0};
|
||||||
|
char path[PATH_MAX + 1] = {0x00};
|
||||||
char *profilePath = GetOneCfgFile(COMPONENTSLOAD_PROFILE_PATH, buf, MAX_PATH_LEN);
|
char *profilePath = GetOneCfgFile(COMPONENTSLOAD_PROFILE_PATH, buf, MAX_PATH_LEN);
|
||||||
if (profilePath == nullptr) {
|
if (strlen(profilePath) == 0 || strlen(profilePath) > PATH_MAX || realpath(profilePath, path) == nullptr) {
|
||||||
DHLOGE("profilePath is null!");
|
DHLOGE("File connicailization failed.");
|
||||||
return ERR_DH_FWK_LOADER_PROFILE_PATH_IS_NULL;
|
return ERR_DH_FWK_LOADER_PROFILE_PATH_IS_NULL;
|
||||||
}
|
}
|
||||||
std::string componentProfilePath(profilePath);
|
std::string componentProfilePath(path);
|
||||||
std::string jsonStr = Readfile(componentProfilePath);
|
std::string jsonStr = Readfile(componentProfilePath);
|
||||||
if (jsonStr.length() == 0 || jsonStr.size() > MAX_MESSAGE_LEN) {
|
if (jsonStr.length() == 0 || jsonStr.size() > MAX_MESSAGE_LEN) {
|
||||||
DHLOGE("ConfigJson size is invalid!");
|
DHLOGE("ConfigJson size is invalid!");
|
||||||
|
Loading…
Reference in New Issue
Block a user