mirror of
https://github.com/openharmony/global_resource_tool.git
synced 2026-06-30 21:18:00 -04:00
1,修改编码规范
2,屏蔽三方开源头文件OAT Signed-off-by: chencheng31 <chencheng8@huawei.com>
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include<iostream>
|
||||
#include<functional>
|
||||
#include<vector>
|
||||
#include "singleton_object.h"
|
||||
#include "singleton.h"
|
||||
#include "resource_data.h"
|
||||
#include "restool_errors.h"
|
||||
|
||||
@@ -136,4 +136,4 @@ uint32_t CmdParser<T>::Parse(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "resource_data.h"
|
||||
#include "resource_item.h"
|
||||
#include "increment_manager.h"
|
||||
#include "singleton_object.h"
|
||||
#include "singleton.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
@@ -48,4 +48,4 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
|
||||
#include<functional>
|
||||
#include<vector>
|
||||
#include "singleton_object.h"
|
||||
#include "singleton.h"
|
||||
#include "resource_data.h"
|
||||
#include "resource_util.h"
|
||||
|
||||
|
||||
@@ -48,11 +48,11 @@ private:
|
||||
SEG_RESOURCE = 0,
|
||||
SEG_LIMIT_KEY = 1,
|
||||
SEG_FILE_CLUSTER = 2,
|
||||
SEG_FILE_NAME =3,
|
||||
SEG_FILE_NAME = 3,
|
||||
SEG_MAX
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include<string>
|
||||
#include "resource_util.h"
|
||||
#include "resource_item.h"
|
||||
#include "singleton_object.h"
|
||||
#include "singleton.h"
|
||||
|
||||
#include "increment_list.h"
|
||||
#include "increment_index.h"
|
||||
@@ -72,4 +72,4 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -30,11 +30,11 @@ public:
|
||||
private:
|
||||
bool CombineDirectory(const DirectoryInfo &directoryInfo);
|
||||
bool CombineSolidXml(const std::string &src, const std::string &dst,
|
||||
const std::map<std::string , std::string> &sxmlPaths);
|
||||
const std::map<std::string ,std::string> &sxmlPaths);
|
||||
const std::string &modulePath_;
|
||||
const std::string &outputPath_;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_RESTOOL_NOCOPYABLE_OBJECT_H
|
||||
#define OHOS_RESTOOL_NOCOPYABLE_OBJECT_H
|
||||
#ifndef OHOS_RESTOOL_NOCOPYABLE_H
|
||||
#define OHOS_RESTOOL_NOCOPYABLE_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
@@ -42,4 +42,4 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -112,7 +112,7 @@ const std::map<std::string, ResolutionType> g_resolutionMap = {
|
||||
{ "ldpi", ResolutionType::LDPI },
|
||||
{ "xldpi", ResolutionType::XLDPI },
|
||||
{ "xxldpi", ResolutionType::XXLDPI },
|
||||
{ "xxxldpi", ResolutionType::XXXLDPI },
|
||||
{ "xxxldpi", ResolutionType::XXXLDPI },
|
||||
};
|
||||
|
||||
enum class NightMode {
|
||||
|
||||
@@ -24,7 +24,8 @@ namespace Global {
|
||||
namespace Restool {
|
||||
class ResourceModuleInc : public ResourceModule {
|
||||
public:
|
||||
ResourceModuleInc(const std::string &modulePath, const std::string &moduleOutput, const std::string &moduleName, const std::vector<std::string> &folder);
|
||||
ResourceModuleInc(const std::string &modulePath, const std::string &moduleOutput,
|
||||
const std::string &moduleName, const std::vector<std::string> &folder);
|
||||
virtual ~ResourceModuleInc() {};
|
||||
uint32_t ScanResource(const std::vector<IncrementList::FileIncrement> &fileIncrements);
|
||||
uint32_t SaveIndex() const;
|
||||
@@ -34,4 +35,4 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
* @brief split the string with given splitter.
|
||||
* @param str: input string.
|
||||
* @param out: the array of strings computed by splitter.
|
||||
* @param splitter: the split string.
|
||||
* @param splitter: the split string.
|
||||
*/
|
||||
static void Split(const std::string &str, std::vector<std::string> &out, const std::string &splitter);
|
||||
|
||||
@@ -66,14 +66,14 @@ public:
|
||||
/**
|
||||
* @brief get resource type from directory.
|
||||
* @param name: directory name.
|
||||
* @return resrouce type.
|
||||
* @return resource type.
|
||||
*/
|
||||
static ResType GetResTypeByDir(const std::string &name);
|
||||
|
||||
/**
|
||||
* @brief ResType to string
|
||||
* @param type: ResType
|
||||
* @return resrouce type string.
|
||||
* @return resource type string.
|
||||
*/
|
||||
static std::string ResTypeToString(ResType type);
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
static std::string GetIdName(const std::string &name, ResType type);
|
||||
|
||||
/**
|
||||
* @brief compose multi strings to string
|
||||
* @brief compose multi strings to string
|
||||
* @param contents: multi strings
|
||||
* @param addNull: if true, string length contains '\0'.
|
||||
* @return return string, empty if error
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
static std::string ComposeStrings(const std::vector<std::string> &contents, bool addNull = false);
|
||||
|
||||
/**
|
||||
* @brief decompose string to multi strings
|
||||
* @brief decompose string to multi strings
|
||||
* @param content: string
|
||||
* @return return string vector, empty if error
|
||||
*/
|
||||
@@ -154,4 +154,4 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#ifndef OHOS_RESTOOL_SINGLETON_OBJECT_H
|
||||
#define OHOS_RESTOOL_SINGLETON_OBJECT_H
|
||||
|
||||
#include "nocopyable_object.h"
|
||||
#include "nocopyable.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
@@ -38,4 +38,4 @@ T Singleton<T>::instance_;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include<string>
|
||||
#include "resource_item.h"
|
||||
#include "singleton_object.h"
|
||||
#include "singleton.h"
|
||||
#include "sqlite3.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -37,11 +37,11 @@ private:
|
||||
bool CreateTable();
|
||||
std::string GetValue(const ResourceItem &resourceItem) const;
|
||||
std::string dbPath_;
|
||||
sqlite3 * db_ = nullptr;
|
||||
sqlite3 *db_ = nullptr;
|
||||
static int32_t id_;
|
||||
int32_t priority_ = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+3
-3
@@ -45,8 +45,8 @@ uint32_t CmdList::Init(const string &filePath, function<uint32_t(int c, const st
|
||||
if (GetArray(root["ResourceTable"], 'r', callback) != RESTOOL_SUCCESS ||
|
||||
GetString(root["applicationResource"], 'i', callback) != RESTOOL_SUCCESS ||
|
||||
GetArray(root["moduleResources"], 'i', callback) != RESTOOL_SUCCESS ||
|
||||
GetArray(root["dependencies"], 'i', callback) != RESTOOL_SUCCESS ) {
|
||||
return RESTOOL_ERROR;
|
||||
GetArray(root["dependencies"], 'i', callback) != RESTOOL_SUCCESS) {
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
callback('f', "");
|
||||
@@ -103,4 +103,4 @@ uint32_t CmdList::GetModuleNames(const Json::Value &node, HandleBack callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -130,7 +130,7 @@ uint32_t PackageParser::AddOutput(const string& argValue)
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
output_ = argValue;
|
||||
output_ = argValue;
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,6 @@ uint32_t PackageParser::AddCachePath(const string& argValue)
|
||||
|
||||
uint32_t PackageParser::CheckParam() const
|
||||
{
|
||||
|
||||
if (inputs_.empty()) {
|
||||
cerr << "Error: input path empty." << endl;
|
||||
return RESTOOL_ERROR;
|
||||
@@ -318,4 +317,4 @@ uint32_t PackageParser::ParseCommand(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ bool ConfigParser::GetRefIdFromString(string &value, bool &update, const string
|
||||
smatch result;
|
||||
if (regex_search(value, result, regex(match))) {
|
||||
value = value.substr(result[0].str().length());
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
cerr << error << endl;
|
||||
return false;
|
||||
@@ -263,4 +263,4 @@ bool ConfigParser::ParseModuleType(const string &type)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -127,7 +127,7 @@ bool FileEntry::IsDirectory(const string &path)
|
||||
{
|
||||
struct stat s;
|
||||
stat(path.c_str(), &s);
|
||||
return S_ISDIR(s.st_mode);
|
||||
return S_ISDIR(s.st_mode);
|
||||
}
|
||||
|
||||
FileEntry::FilePath::FilePath(const string &path) : filePath_(path)
|
||||
@@ -198,10 +198,10 @@ const vector<string> FileEntry::FilePath::GetSegments() const
|
||||
// below private
|
||||
bool FileEntry::IsIgnore(const string &filename) const
|
||||
{
|
||||
if (filename == "." || filename == "..") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (filename == "." || filename == "..") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileEntry::RemoveAllDirInner(const FileEntry &entry)
|
||||
@@ -224,7 +224,7 @@ bool FileEntry::CreateDirsInner(const string &path, string::size_type offset)
|
||||
if (pos == string::npos) {
|
||||
#if _WIN32
|
||||
return mkdir(path.c_str());
|
||||
#else
|
||||
#else
|
||||
return mkdir(path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0;
|
||||
#endif
|
||||
}
|
||||
@@ -242,7 +242,7 @@ bool FileEntry::CreateDirsInner(const string &path, string::size_type offset)
|
||||
return CreateDirsInner(path, pos + 1);
|
||||
}
|
||||
|
||||
void FileEntry::FilePath::Format()
|
||||
void FileEntry::FilePath::Format()
|
||||
{
|
||||
if (filePath_.back() != SEPARATE.front()) {
|
||||
return;
|
||||
@@ -264,8 +264,8 @@ void FileEntry::FilePath::Init()
|
||||
pos = filename_.find_last_of('.');
|
||||
if (pos != string::npos && pos + 1 < filename_.length()) {
|
||||
extension_ = filename_.substr(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ uint32_t FileManager::ScanModules(const vector<string> &inputs, const string &ou
|
||||
vector<string> sxmlFolders;
|
||||
for (auto input : inputs) {
|
||||
map<ResType, vector<DirectoryInfo>> resTypeOfDirs;
|
||||
if(ScanModule(input, output, resTypeOfDirs) != RESTOOL_SUCCESS) {
|
||||
if (ScanModule(input, output, resTypeOfDirs) != RESTOOL_SUCCESS) {
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
FilterRefSolidXml(output, sxmlFolders, resTypeOfDirs);
|
||||
@@ -100,7 +100,7 @@ void FileManager::FilterRefSolidXml(const string &output, vector<string> &output
|
||||
string outputPath = FileEntry::FilePath(output).Append(RESOURCES_DIR).Append(resourceDir.limitKey)
|
||||
.Append(resourceDir.fileCluster).GetPath();
|
||||
if (find(outputPaths.begin(), outputPaths.end(), outputPath) == outputPaths.end()) {
|
||||
outputPaths.push_back(outputPath);
|
||||
outputPaths.push_back(outputPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,12 +144,12 @@ uint32_t IResourceCompiler::ConvertToSolidXml(const map<string, vector<FileInfo>
|
||||
|
||||
uint32_t IResourceCompiler::CompileSingleFile(const FileInfo &fileInfo)
|
||||
{
|
||||
return RESTOOL_SUCCESS;
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t IResourceCompiler::PostCommit()
|
||||
{
|
||||
IdWorker &idWorker = IdWorker::GetInstance();
|
||||
IdWorker &idWorker = IdWorker::GetInstance();
|
||||
for (const auto &nameInfo : nameInfos_) {
|
||||
int32_t id = idWorker.GenerateId(nameInfo.first.first, nameInfo.first.second);
|
||||
if (id < 0) {
|
||||
@@ -159,7 +159,7 @@ uint32_t IResourceCompiler::PostCommit()
|
||||
}
|
||||
resourceInfos_.emplace(id, nameInfo.second);
|
||||
}
|
||||
return RESTOOL_SUCCESS;
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
bool IResourceCompiler::MergeResourceItem(const ResourceItem &resourceItem)
|
||||
@@ -236,4 +236,4 @@ string IResourceCompiler::GetOutputFolder(const DirectoryInfo &directoryInfo) co
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,9 @@ void IncrementManager::DeleteRawFile(vector<IncrementList::FileIncrement> &dels)
|
||||
continue;
|
||||
}
|
||||
string rawFilePath = FileEntry::FilePath(outputPath_).Append(it->relativePath).GetPath();
|
||||
remove(rawFilePath.c_str());
|
||||
if (remove(rawFilePath.c_str()) != 0) {
|
||||
cout << "Warning: remove fail '" << rawFilePath << "'" << endl;
|
||||
}
|
||||
it = dels.erase(it);
|
||||
}
|
||||
}
|
||||
@@ -277,4 +279,4 @@ bool IncrementManager::ClearSolidXml() const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ bool JsonCompiler::HandleStringArray(const Json::Value &objectNode, ResourceItem
|
||||
}
|
||||
values.push_back(value.asString());
|
||||
return true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
bool JsonCompiler::HandleIntegerArray(const Json::Value &objectNode, ResourceItem &resourceItem) const
|
||||
@@ -444,7 +444,7 @@ bool JsonCompiler::CheckPluralValue(const Json::Value &arrayItem, const Resource
|
||||
if (find(QUANTITY_ATTRS.begin(), QUANTITY_ATTRS.end(), quantityValue) == QUANTITY_ATTRS.end()) {
|
||||
string buffer(" ");
|
||||
for_each(QUANTITY_ATTRS.begin(), QUANTITY_ATTRS.end(), [&buffer](auto iter) {
|
||||
buffer.append(iter).append(" ");
|
||||
buffer.append(iter).append(" ");
|
||||
});
|
||||
cerr << "Error: Plural '" << resourceItem.GetName() << "' quantity '" << quantityValue;
|
||||
cerr << "' not in [" << buffer << "]," << resourceItem.GetFilePath() << endl;
|
||||
@@ -466,4 +466,4 @@ bool JsonCompiler::CheckPluralValue(const Json::Value &arrayItem, const Resource
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,10 @@ PreviewManager::~PreviewManager()
|
||||
|
||||
uint32_t PreviewManager::ScanModules(const vector<string> &modulePaths, const string &output)
|
||||
{
|
||||
|
||||
SqliteDatabase &database = SqliteDatabase::GetInstance();
|
||||
string dbPath = FileEntry::FilePath(output).Append("resources.db").GetPath();
|
||||
database.Init(dbPath);
|
||||
if(!database.OpenDatabase()) {
|
||||
if (!database.OpenDatabase()) {
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
@@ -99,4 +98,4 @@ bool PreviewManager::ScanFile(const string &filePath, int32_t priority)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ uint32_t ReferenceParser::ParseRefInProfile(const string &output) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entry->GetFilePath().GetExtension() != ".json" ) {
|
||||
if (entry->GetFilePath().GetExtension() != ".json") {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ bool ReferenceParser::ParseRefJsonImpl(Json::Value &node) const
|
||||
}
|
||||
} else if (node.isArray()) {
|
||||
for (Json::ArrayIndex i = 0; i < node.size(); i++) {
|
||||
if (!ParseRefJsonImpl(node[i])) {
|
||||
if (!ParseRefJsonImpl(node[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -320,4 +320,4 @@ bool ReferenceParser::ParseRefJsonImpl(Json::Value &node) const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ bool ResourceDirectory::ScanResources(const string &resourcesDir, function<bool(
|
||||
|
||||
// below private
|
||||
bool ResourceDirectory::ScanResourceLimitKeyDir(const string &resourceTypeDir, const string &limitKey,
|
||||
function<bool(const DirectoryInfo&)> callback) const
|
||||
function<bool(const DirectoryInfo&)> callback) const
|
||||
{
|
||||
vector<KeyParam> keyParams;
|
||||
if (!KeyParser::Parse(limitKey, keyParams)) {
|
||||
@@ -70,7 +70,7 @@ bool ResourceDirectory::ScanResourceLimitKeyDir(const string &resourceTypeDir, c
|
||||
string fileCluster = it->GetFilePath().GetFilename();
|
||||
if (ResourceUtil::IsIgnoreFile(fileCluster, it->IsFile())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (it->IsFile()) {
|
||||
cerr << "Error: '" << dirPath << "' not directory." << endl;
|
||||
@@ -97,4 +97,4 @@ bool ResourceDirectory::ScanResourceLimitKeyDir(const string &resourceTypeDir, c
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ uint32_t ResourceModule::ScanResource()
|
||||
}
|
||||
|
||||
ResourceDirectory directory;
|
||||
if (!directory.ScanResources(modulePath_,[this](const DirectoryInfo &info) -> bool {
|
||||
if (!directory.ScanResources(modulePath_, [this](const DirectoryInfo &info) -> bool {
|
||||
scanDirs_[info.dirType].push_back(info);
|
||||
return true;
|
||||
})) {
|
||||
@@ -79,7 +79,7 @@ const map<ResType, vector<DirectoryInfo>> &ResourceModule::GetScanDirectorys() c
|
||||
}
|
||||
|
||||
uint32_t ResourceModule::MergeResourceItem(map<int32_t, vector<ResourceItem>> &alls,
|
||||
const map<int32_t, vector<ResourceItem>> &other, bool tipError)
|
||||
const map<int32_t, vector<ResourceItem>> &other, bool tipError)
|
||||
{
|
||||
for (const auto &iter : other) {
|
||||
auto result = alls.emplace(iter.first, iter.second);
|
||||
@@ -119,4 +119,4 @@ void ResourceModule::Push(const map<int32_t, std::vector<ResourceItem>> &other)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ uint32_t ResourcePack::Init()
|
||||
}
|
||||
|
||||
uint32_t ResourcePack::InitModule()
|
||||
{
|
||||
{
|
||||
IdWorker::ResourceIdCluster hapType = IdWorker::ResourceIdCluster::RES_ID_APP;
|
||||
string packageName = packageParser_.GetPackageName();
|
||||
if (packageName == "ohos.global.systemres") {
|
||||
@@ -360,4 +360,4 @@ uint32_t ResourcePack::ScanResources(const vector<string> &inputs, const string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Restool {
|
||||
using namespace std;
|
||||
ResourceTable::ResourceTable()
|
||||
{
|
||||
auto &parser =CmdParser<PackageParser>::GetInstance();
|
||||
auto &parser = CmdParser<PackageParser>::GetInstance();
|
||||
auto &packageParser = parser.GetCmdParser();
|
||||
indexFilePath_ = FileEntry::FilePath(packageParser.GetOutput()).Append(RESOURCE_INDEX_FILE).GetPath();
|
||||
}
|
||||
@@ -58,7 +58,7 @@ uint32_t ResourceTable::CreateResourceTable()
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
//below private
|
||||
// below private
|
||||
uint32_t ResourceTable::SaveToResouorceIndex(const map<string, vector<TableData>> &configs) const
|
||||
{
|
||||
uint32_t pos = 0;
|
||||
@@ -173,7 +173,7 @@ bool ResourceTable::SaveRecordItem(const map<string, vector<TableData>> &configs
|
||||
out.write(reinterpret_cast<const char *>(&recordItem.resType), sizeof(uint32_t));
|
||||
out.write(reinterpret_cast<const char *>(&recordItem.id), sizeof(uint32_t));
|
||||
out.write(reinterpret_cast<const char *>(data.c_str()), data.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ bool ResourceUtil::OpenJsonFile(const string &path, Json::Value &root)
|
||||
cerr << "Error: parseFromStream '" << path;
|
||||
cerr << "\n" << errs << endl;
|
||||
ifs.close();
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
ifs.close();
|
||||
return true;
|
||||
@@ -182,7 +182,7 @@ vector<string> ResourceUtil::DecomposeStrings(const string &content)
|
||||
while (pos < length) {
|
||||
if (pos + HEAD_LENGTH >= length) {
|
||||
result.clear();
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
uint16_t size = (content[pos] & 0xff) | ((content[pos + 1] & 0xff) << 8);
|
||||
pos += HEAD_LENGTH;
|
||||
|
||||
+3
-2
@@ -18,7 +18,7 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Global::Restool;
|
||||
|
||||
namespace {
|
||||
uint32_t ProccssHap(PackageParser &packageParser)
|
||||
{
|
||||
TaskHandle taskHandle;
|
||||
@@ -29,6 +29,7 @@ uint32_t PackCmdHandle(PackageParser &packageParser)
|
||||
{
|
||||
return ProccssHap(packageParser);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -44,4 +45,4 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
cout << "Info: restool resources compile success." << endl;
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ bool SqliteDatabase::Insert(const ResourceItem &resourceItem)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id >= 0 ) {
|
||||
if (id >= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -186,11 +186,11 @@ string SqliteDatabase::GetValue(const ResourceItem &resourceItem) const
|
||||
string data(reinterpret_cast<const char *>(resourceItem.GetData()), resourceItem.GetDataLength());
|
||||
if (resourceItem.GetResType() == ResType::STRARRAY || resourceItem.GetResType() == ResType::INTARRAY ||
|
||||
resourceItem.GetResType() == ResType::THEME || resourceItem.GetResType() == ResType::PATTERN ||
|
||||
resourceItem.GetResType() == ResType::PLURAL ) {
|
||||
resourceItem.GetResType() == ResType::PLURAL) {
|
||||
vector<string> contents = ResourceUtil::DecomposeStrings(data);
|
||||
Json::Value array(Json::arrayValue);
|
||||
for (const auto &iter : contents) {
|
||||
array.append(iter);
|
||||
array.append(iter);
|
||||
}
|
||||
data = array.toStyledString();
|
||||
}
|
||||
@@ -198,4 +198,4 @@ string SqliteDatabase::GetValue(const ResourceItem &resourceItem) const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,12 +270,12 @@ bool SolidXml::SaveToFile(const std::string &filePath) const
|
||||
|
||||
// write namespace
|
||||
for (const auto &nameSpace : nameSpaces_) {
|
||||
out.write(reinterpret_cast<const char *>(&nameSpace), sizeof(int32_t));
|
||||
out.write(reinterpret_cast<const char *>(&nameSpace), sizeof(int32_t));
|
||||
}
|
||||
|
||||
// write href
|
||||
for (const auto &href : hrefs_) {
|
||||
out.write(reinterpret_cast<const char *>(&href), sizeof(int32_t));
|
||||
out.write(reinterpret_cast<const char *>(&href), sizeof(int32_t));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -377,4 +377,4 @@ bool SolidXml::FlushXmlnsKey(map<XmlKeyNode::KeyType, shared_ptr<XmlKeyNode>> &n
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ bool XmlConverter::GenerateSolidXml()
|
||||
|
||||
bool XmlConverter::GenerateKey()
|
||||
{
|
||||
return keyManager.SaveKey(outputPath_);
|
||||
return keyManager.SaveKey(outputPath_);
|
||||
}
|
||||
|
||||
bool XmlConverter::LoadKeys(const std::string &folderPath)
|
||||
{
|
||||
return keyManager.LoadKey(folderPath);
|
||||
return keyManager.LoadKey(folderPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user