diff --git a/OTA.xml b/OAT.xml similarity index 100% rename from OTA.xml rename to OAT.xml diff --git a/include/cmd_parser.h b/include/cmd_parser.h index 1f120fb..98e7510 100644 --- a/include/cmd_parser.h +++ b/include/cmd_parser.h @@ -20,7 +20,7 @@ #include #include #include -#include "singleton_object.h" +#include "singleton.h" #include "resource_data.h" #include "restool_errors.h" @@ -136,4 +136,4 @@ uint32_t CmdParser::Parse(int argc, char *argv[]) } } } -#endif \ No newline at end of file +#endif diff --git a/include/file_manager.h b/include/file_manager.h index 6fd5f0f..c19802e 100644 --- a/include/file_manager.h +++ b/include/file_manager.h @@ -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 \ No newline at end of file +#endif diff --git a/include/id_worker.h b/include/id_worker.h index 5ed46ff..0e90688 100644 --- a/include/id_worker.h +++ b/include/id_worker.h @@ -18,7 +18,7 @@ #include #include -#include "singleton_object.h" +#include "singleton.h" #include "resource_data.h" #include "resource_util.h" diff --git a/include/increment_list.h b/include/increment_list.h index ea906c6..bfa90e7 100644 --- a/include/increment_list.h +++ b/include/increment_list.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 \ No newline at end of file +#endif diff --git a/include/increment_manager.h b/include/increment_manager.h index 918314d..de60447 100644 --- a/include/increment_manager.h +++ b/include/increment_manager.h @@ -19,7 +19,7 @@ #include #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 \ No newline at end of file +#endif diff --git a/include/module_combine.h b/include/module_combine.h index 735180b..9da8df4 100644 --- a/include/module_combine.h +++ b/include/module_combine.h @@ -30,11 +30,11 @@ public: private: bool CombineDirectory(const DirectoryInfo &directoryInfo); bool CombineSolidXml(const std::string &src, const std::string &dst, - const std::map &sxmlPaths); + const std::map &sxmlPaths); const std::string &modulePath_; const std::string &outputPath_; }; } } } -#endif \ No newline at end of file +#endif diff --git a/include/nocopyable_object.h b/include/no_copy_able.h similarity index 92% rename from include/nocopyable_object.h rename to include/no_copy_able.h index e104fac..e301d31 100644 --- a/include/nocopyable_object.h +++ b/include/no_copy_able.h @@ -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 \ No newline at end of file +#endif diff --git a/include/resource_data.h b/include/resource_data.h index d714d21..7487426 100644 --- a/include/resource_data.h +++ b/include/resource_data.h @@ -112,7 +112,7 @@ const std::map g_resolutionMap = { { "ldpi", ResolutionType::LDPI }, { "xldpi", ResolutionType::XLDPI }, { "xxldpi", ResolutionType::XXLDPI }, - { "xxxldpi", ResolutionType::XXXLDPI }, + { "xxxldpi", ResolutionType::XXXLDPI }, }; enum class NightMode { diff --git a/include/resource_module_inc.h b/include/resource_module_inc.h index 9998579..ac9ba5d 100644 --- a/include/resource_module_inc.h +++ b/include/resource_module_inc.h @@ -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 &folder); + ResourceModuleInc(const std::string &modulePath, const std::string &moduleOutput, + const std::string &moduleName, const std::vector &folder); virtual ~ResourceModuleInc() {}; uint32_t ScanResource(const std::vector &fileIncrements); uint32_t SaveIndex() const; @@ -34,4 +35,4 @@ private: } } } -#endif \ No newline at end of file +#endif diff --git a/include/resource_util.h b/include/resource_util.h index 8a17b7f..f61e752 100644 --- a/include/resource_util.h +++ b/include/resource_util.h @@ -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 &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 &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 \ No newline at end of file +#endif diff --git a/include/singleton_object.h b/include/singleton.h similarity index 96% rename from include/singleton_object.h rename to include/singleton.h index 103412b..c93c215 100644 --- a/include/singleton_object.h +++ b/include/singleton.h @@ -16,7 +16,7 @@ #ifndef OHOS_RESTOOL_SINGLETON_OBJECT_H #define OHOS_RESTOOL_SINGLETON_OBJECT_H -#include "nocopyable_object.h" +#include "no_copy_able.h" namespace OHOS { namespace Global { @@ -38,4 +38,4 @@ T Singleton::instance_; } } } -#endif \ No newline at end of file +#endif diff --git a/include/sqlite_database.h b/include/sqlite_database.h index 08c511b..508b8be 100644 --- a/include/sqlite_database.h +++ b/include/sqlite_database.h @@ -18,7 +18,7 @@ #include #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 \ No newline at end of file +#endif diff --git a/src/cmd_list.cpp b/src/cmd_list.cpp index de2e327..7c8e45b 100644 --- a/src/cmd_list.cpp +++ b/src/cmd_list.cpp @@ -45,8 +45,8 @@ uint32_t CmdList::Init(const string &filePath, function 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); - } + } +} } } } -} \ No newline at end of file diff --git a/src/file_manager.cpp b/src/file_manager.cpp index 8ed66e1..5a14b0a 100644 --- a/src/file_manager.cpp +++ b/src/file_manager.cpp @@ -35,7 +35,7 @@ uint32_t FileManager::ScanModules(const vector &inputs, const string &ou vector sxmlFolders; for (auto input : inputs) { map> 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 &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); } } } diff --git a/src/i_resource_compiler.cpp b/src/i_resource_compiler.cpp index 09b0edc..0b3e53d 100644 --- a/src/i_resource_compiler.cpp +++ b/src/i_resource_compiler.cpp @@ -144,12 +144,12 @@ uint32_t IResourceCompiler::ConvertToSolidXml(const map 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 } } } -} \ No newline at end of file +} diff --git a/src/increment_manager.cpp b/src/increment_manager.cpp index c834a25..306dab8 100644 --- a/src/increment_manager.cpp +++ b/src/increment_manager.cpp @@ -230,7 +230,9 @@ void IncrementManager::DeleteRawFile(vector &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 } } } -} \ No newline at end of file +} diff --git a/src/json_compiler.cpp b/src/json_compiler.cpp index 2b40172..023893b 100644 --- a/src/json_compiler.cpp +++ b/src/json_compiler.cpp @@ -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 } } } -} \ No newline at end of file +} diff --git a/src/module_combine.cpp b/src/module_combine.cpp index 81ae75a..a579e4c 100644 --- a/src/module_combine.cpp +++ b/src/module_combine.cpp @@ -89,7 +89,7 @@ bool ModuleCombine::CombineDirectory(const DirectoryInfo &directoryInfo) return CombineSolidXml(directoryInfo.dirPath, outputFolder, sxmlPaths); } -bool ModuleCombine::CombineSolidXml(const string &src, const string &dst, const map &sxmlPaths) +bool ModuleCombine::CombineSolidXml(const string &src, const string &dst, const map &sxmlPaths) { if (sxmlPaths.empty()) { return true; @@ -120,4 +120,4 @@ bool ModuleCombine::CombineSolidXml(const string &src, const string &dst, const } } } -} \ No newline at end of file +} diff --git a/src/preview_manager.cpp b/src/preview_manager.cpp index 5814855..2eef2ca 100644 --- a/src/preview_manager.cpp +++ b/src/preview_manager.cpp @@ -34,11 +34,10 @@ PreviewManager::~PreviewManager() uint32_t PreviewManager::ScanModules(const vector &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) } } } -} \ No newline at end of file +} diff --git a/src/reference_parser.cpp b/src/reference_parser.cpp index abc55b3..7467382 100644 --- a/src/reference_parser.cpp +++ b/src/reference_parser.cpp @@ -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 } } } -} \ No newline at end of file +} diff --git a/src/resource_directory.cpp b/src/resource_directory.cpp index c9a37ab..ebef655 100644 --- a/src/resource_directory.cpp +++ b/src/resource_directory.cpp @@ -53,7 +53,7 @@ bool ResourceDirectory::ScanResources(const string &resourcesDir, function callback) const + function callback) const { vector 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 } } } -} \ No newline at end of file +} diff --git a/src/resource_module.cpp b/src/resource_module.cpp index d018321..0724693 100644 --- a/src/resource_module.cpp +++ b/src/resource_module.cpp @@ -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> &ResourceModule::GetScanDirectorys() c } uint32_t ResourceModule::MergeResourceItem(map> &alls, - const map> &other, bool tipError) + const map> &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> &other) } } } -} \ No newline at end of file +} diff --git a/src/resource_pack.cpp b/src/resource_pack.cpp index 7cc7a67..77bc355 100644 --- a/src/resource_pack.cpp +++ b/src/resource_pack.cpp @@ -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 &inputs, const string } } } -} \ No newline at end of file +} diff --git a/src/resource_table.cpp b/src/resource_table.cpp index 4a2fcbc..dc716dc 100644 --- a/src/resource_table.cpp +++ b/src/resource_table.cpp @@ -26,7 +26,7 @@ namespace Restool { using namespace std; ResourceTable::ResourceTable() { - auto &parser =CmdParser::GetInstance(); + auto &parser = CmdParser::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> &configs) const { uint32_t pos = 0; @@ -173,7 +173,7 @@ bool ResourceTable::SaveRecordItem(const map> &configs out.write(reinterpret_cast(&recordItem.resType), sizeof(uint32_t)); out.write(reinterpret_cast(&recordItem.id), sizeof(uint32_t)); out.write(reinterpret_cast(data.c_str()), data.length()); - } + } } return true; } diff --git a/src/resource_util.cpp b/src/resource_util.cpp index 51a699c..3fcc3fc 100644 --- a/src/resource_util.cpp +++ b/src/resource_util.cpp @@ -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 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; diff --git a/src/restool.cpp b/src/restool.cpp index 3da2fca..135ed98 100644 --- a/src/restool.cpp +++ b/src/restool.cpp @@ -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; -} \ No newline at end of file +} diff --git a/src/sqlite_database.cpp b/src/sqlite_database.cpp index 21563fe..bbd16dc 100644 --- a/src/sqlite_database.cpp +++ b/src/sqlite_database.cpp @@ -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(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 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 } } } -} \ No newline at end of file +} diff --git a/src/xml/solid_xml.cpp b/src/xml/solid_xml.cpp index 50645b0..c1fbee7 100644 --- a/src/xml/solid_xml.cpp +++ b/src/xml/solid_xml.cpp @@ -270,12 +270,12 @@ bool SolidXml::SaveToFile(const std::string &filePath) const // write namespace for (const auto &nameSpace : nameSpaces_) { - out.write(reinterpret_cast(&nameSpace), sizeof(int32_t)); + out.write(reinterpret_cast(&nameSpace), sizeof(int32_t)); } // write href for (const auto &href : hrefs_) { - out.write(reinterpret_cast(&href), sizeof(int32_t)); + out.write(reinterpret_cast(&href), sizeof(int32_t)); } return true; } @@ -377,4 +377,4 @@ bool SolidXml::FlushXmlnsKey(map> &n } } } -} \ No newline at end of file +} diff --git a/src/xml/xml_converter.cpp b/src/xml/xml_converter.cpp index 826a4a1..4307a25 100644 --- a/src/xml/xml_converter.cpp +++ b/src/xml/xml_converter.cpp @@ -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); +} } } } -} \ No newline at end of file