diff --git a/include/cmd/package_parser.h b/include/cmd/package_parser.h index 8304036..4d409a4 100644 --- a/include/cmd/package_parser.h +++ b/include/cmd/package_parser.h @@ -60,6 +60,7 @@ private: uint32_t ParseCommand(int argc, char *argv[]); uint32_t CheckError(int argc, char *argv[], int c, int optIndex); uint32_t AddInput(const std::string &argValue); + bool IsOverlapInput(const std::string& inputPath); uint32_t AddPackageName(const std::string &argValue); uint32_t AddOutput(const std::string &argValue); uint32_t AddResourceHeader(const std::string &argValue); @@ -111,6 +112,7 @@ private: std::vector sysIdDefinedPaths_; std::string compressionPath_; size_t threadCount_{ 0 }; + bool isOverlap_{ false }; }; } // namespace Restool } // namespace Global diff --git a/src/cmd/package_parser.cpp b/src/cmd/package_parser.cpp index 5dc80d6..85daed2 100644 --- a/src/cmd/package_parser.cpp +++ b/src/cmd/package_parser.cpp @@ -139,9 +139,7 @@ uint32_t PackageParser::AddInput(const string& argValue) return RESTOOL_ERROR; } - string indexPath = FileEntry::FilePath(inputPath).Append(RESOURCE_INDEX_FILE).GetPath(); - string indexPathJson = ResourceUtil::GetMainPath(inputPath).Append(RESOURCE_INDEX_FILE).GetPath(); - if (ResourceUtil::FileExist(indexPath) || ResourceUtil::FileExist(indexPathJson)) { + if (IsOverlapInput(inputPath)) { inputs_.emplace(inputs_.begin(), inputPath); } else { inputs_.push_back(inputPath); @@ -149,6 +147,33 @@ uint32_t PackageParser::AddInput(const string& argValue) return RESTOOL_SUCCESS; } +bool PackageParser::IsOverlapInput(const string& inputPath) +{ + if (isOverlap_) { + return false; + } + + string indexPath = FileEntry::FilePath(inputPath).Append(RESOURCE_INDEX_FILE).GetPath(); + if (ResourceUtil::FileExist(indexPath)) { + isOverlap_ = true; + return true; + } + + string jsonIndexPath = ResourceUtil::GetMainPath(inputPath).Append(RESOURCE_INDEX_FILE).GetPath(); + string txtResHeaderPath = ResourceUtil::GetMainPath(inputPath).Append("ResourceTable.txt").GetPath(); + string jsResHeaderPath = ResourceUtil::GetMainPath(inputPath).Append("ResourceTable.js").GetPath(); + string hResJsHeaderPath = ResourceUtil::GetMainPath(inputPath).Append("ResourceTable.h").GetPath(); + if (ResourceUtil::FileExist(jsonIndexPath) && + !ResourceUtil::FileExist(txtResHeaderPath) && + !ResourceUtil::FileExist(jsResHeaderPath) && + !ResourceUtil::FileExist(hResJsHeaderPath)) { + isOverlap_ = true; + return true; + } + + return false; +} + uint32_t PackageParser::AddSysIdDefined(const std::string& argValue) { string sysIdDefinedPath = ResourceUtil::RealPath(argValue); @@ -481,11 +506,7 @@ const std::string &PackageParser::GetCompressionPath() const bool PackageParser::IsOverlap() const { - string indexPath = ResourceUtil::GetMainPath(inputs_[0]).Append(RESOURCE_INDEX_FILE).GetPath(); - if (ResourceUtil::FileExist(indexPath)) { - return true; - } - return false; + return isOverlap_; } void PackageParser::InitCommand()