13920e296Sopenharmony_ci/*
23920e296Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
33920e296Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43920e296Sopenharmony_ci * you may not use this file except in compliance with the License.
53920e296Sopenharmony_ci * You may obtain a copy of the License at
63920e296Sopenharmony_ci *
73920e296Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
83920e296Sopenharmony_ci *
93920e296Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103920e296Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113920e296Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123920e296Sopenharmony_ci * See the License for the specific language governing permissions and
133920e296Sopenharmony_ci * limitations under the License.
143920e296Sopenharmony_ci */
153920e296Sopenharmony_ci
163920e296Sopenharmony_ci#include "append_compiler.h"
173920e296Sopenharmony_ci#include <iostream>
183920e296Sopenharmony_ci#include "restool_errors.h"
193920e296Sopenharmony_ci
203920e296Sopenharmony_cinamespace OHOS {
213920e296Sopenharmony_cinamespace Global {
223920e296Sopenharmony_cinamespace Restool {
233920e296Sopenharmony_ciusing namespace std;
243920e296Sopenharmony_ciAppendCompiler::AppendCompiler(ResType type, const string &output) : IResourceCompiler(type, output)
253920e296Sopenharmony_ci{
263920e296Sopenharmony_ci}
273920e296Sopenharmony_ci
283920e296Sopenharmony_ciuint32_t AppendCompiler::CompileSingleFile(const FileInfo &fileInfo)
293920e296Sopenharmony_ci{
303920e296Sopenharmony_ci    ResourceItem resourceItem(fileInfo.filename, fileInfo.keyParams, type_);
313920e296Sopenharmony_ci    resourceItem.SetFilePath(fileInfo.filePath);
323920e296Sopenharmony_ci    resourceItem.SetLimitKey(fileInfo.limitKey);
333920e296Sopenharmony_ci
343920e296Sopenharmony_ci    string data = fileInfo.filePath;
353920e296Sopenharmony_ci    if (!resourceItem.SetData(reinterpret_cast<const int8_t *>(data.c_str()), data.length())) {
363920e296Sopenharmony_ci        cerr << "Error: resource item set data fail, data: " << data << NEW_LINE_PATH << fileInfo.filePath << endl;
373920e296Sopenharmony_ci        return RESTOOL_ERROR;
383920e296Sopenharmony_ci    }
393920e296Sopenharmony_ci
403920e296Sopenharmony_ci    if (!MergeResourceItem(resourceItem)) {
413920e296Sopenharmony_ci        return RESTOOL_ERROR;
423920e296Sopenharmony_ci    }
433920e296Sopenharmony_ci    return RESTOOL_SUCCESS;
443920e296Sopenharmony_ci}
453920e296Sopenharmony_ci}
463920e296Sopenharmony_ci}
473920e296Sopenharmony_ci}