1 /*
2 * Copyright (c) 2020 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "bundle_extractor.h"
17
18 #include "cJSON.h"
19
20 #include "appexecfwk_errors.h"
21 #include "bundle_common.h"
22 #include "bundle_util.h"
23 #include "extractor_util.h"
24 #include "log.h"
25
26 namespace OHOS {
ExtractHapProfile(const std::string & hapFile,std::ostringstream & profileStream)27 uint8_t BundleExtractor::ExtractHapProfile(const std::string &hapFile, std::ostringstream &profileStream)
28 {
29 ExtractorUtil extractorUtil(hapFile);
30 if (!extractorUtil.Init()) {
31 HILOG_ERROR(HILOG_MODULE_APP, "BundleExtractor ExtractHapProfile init fail");
32 return ERR_APPEXECFWK_INSTALL_FAILED_EXTRACTOR_NOT_INIT;
33 }
34
35 if (!extractorUtil.ExtractFileByName(PROFILE_NAME, profileStream)) {
36 HILOG_ERROR(HILOG_MODULE_APP, "it can not find json file!");
37 return ERR_APPEXECFWK_INSTALL_FAILED_PARSE_PROFILE_ERROR;
38 }
39 return ERR_OK;
40 }
41 } // namespace OHOS
42