1/*
2 * Copyright (c) 2022 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 "append_compiler.h"
17#include <iostream>
18#include "restool_errors.h"
19
20namespace OHOS {
21namespace Global {
22namespace Restool {
23using namespace std;
24AppendCompiler::AppendCompiler(ResType type, const string &output) : IResourceCompiler(type, output)
25{
26}
27
28uint32_t AppendCompiler::CompileSingleFile(const FileInfo &fileInfo)
29{
30    ResourceItem resourceItem(fileInfo.filename, fileInfo.keyParams, type_);
31    resourceItem.SetFilePath(fileInfo.filePath);
32    resourceItem.SetLimitKey(fileInfo.limitKey);
33
34    string data = fileInfo.filePath;
35    if (!resourceItem.SetData(reinterpret_cast<const int8_t *>(data.c_str()), data.length())) {
36        cerr << "Error: resource item set data fail, data: " << data << NEW_LINE_PATH << fileInfo.filePath << endl;
37        return RESTOOL_ERROR;
38    }
39
40    if (!MergeResourceItem(resourceItem)) {
41        return RESTOOL_ERROR;
42    }
43    return RESTOOL_SUCCESS;
44}
45}
46}
47}