Files
developtools_global_resourc…/include/resource_append.h
T
fangyunzhong b6e02db9e5 编码规范修改
Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
2022-09-12 14:34:41 +08:00

67 lines
2.9 KiB
C++

/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_RESTOOL_RESOURCE_APPEND_H
#define OHOS_RESTOOL_RESOURCE_APPEND_H
#include <fstream>
#include "cmd_parser.h"
#include "factory_resource_compiler.h"
#include "file_entry.h"
namespace OHOS {
namespace Global {
namespace Restool {
class ResourceAppend {
public:
ResourceAppend(const PackageParser &packageParser);
virtual ~ResourceAppend() {};
uint32_t Append();
uint32_t Combine();
private:
bool Combine(const std::string &folderPath);
bool ScanResources(const std::string &resourcePath, const std::string &outputPath);
bool ScanIegalResources(const std::string &resourcePath, const std::string &outputPath);
bool ScanLimitKey(const std::unique_ptr<FileEntry> &entry, const std::string &limitKey,
const std::string outputPath);
bool ScanFiles(const std::unique_ptr<FileEntry> &entry, const DirectoryInfo &directoryInfo,
const std::string &outputPath);
bool ScanFile(const FileInfo &fileInfo, const std::string &outputPath);
bool ScanSingleFile(const std::string &filePath, const std::string &outputPath);
bool WriteFileInner(std::ostringstream &outStream, const std::string &outputPath) const;
bool WriteResourceItem(const ResourceItem &resourceItem, std::ostringstream &out);
bool LoadResourceItem(const std::string &filePath);
bool ScanRawFiles(const std::string &path, const std::string &outputPath);
bool WriteRawFile(const std::string &filePath, const std::string &outputPath);
bool Push(const std::shared_ptr<ResourceItem> &resourceItem);
void AddRef(const std::shared_ptr<ResourceItem> &resourceItem);
bool LoadResourceItemFromMem(const char buffer[], int32_t length);
std::string ParseString(const char buffer[], int32_t length, int32_t &offset) const;
int32_t ParseInt32(const char buffer[], int32_t length, int32_t &offset) const;
bool ParseRef();
bool CheckModuleResourceItem(const std::shared_ptr<ResourceItem> &resourceItem, int32_t id);
#ifdef __WIN32
bool LoadResourceItemWin(const std::string &filePath);
#endif
const PackageParser &packageParser_;
std::map<int32_t, std::vector<std::shared_ptr<ResourceItem>>> items_;
std::map<int32_t, std::vector<std::shared_ptr<ResourceItem>>> itemsForModule_;
std::vector<std::shared_ptr<ResourceItem>> refs_;
};
}
}
}
#endif