mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-10-07 16:33:53 +00:00
Rename base_extractor to runtime_extractor.
Signed-off-by: dy_study <dingyao5@huawei.com> Change-Id: I54900f59e45d95097a93c19f3a3e47bc416fc163
This commit is contained in:
parent
89ea9edaa8
commit
3c6e643536
@ -51,7 +51,7 @@ config("ability_extractor_config") {
|
||||
|
||||
ohos_source_set("runtime_extractor") {
|
||||
sources = [
|
||||
"utils/src/base_extractor.cpp",
|
||||
"utils/src/runtime_extractor.cpp",
|
||||
"utils/src/zip_file.cpp",
|
||||
]
|
||||
|
||||
|
@ -19,15 +19,15 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "base_extractor.h"
|
||||
#include "js_module_searcher.h"
|
||||
#include "runtime_extractor.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class JsModuleReader final : private JsModuleSearcher {
|
||||
public:
|
||||
JsModuleReader(const std::string& bundleName, const std::string& hapPath,
|
||||
const std::shared_ptr<BaseExtractor>& runtimeExtractor)
|
||||
const std::shared_ptr<RuntimeExtractor>& runtimeExtractor)
|
||||
: JsModuleSearcher(bundleName), hapPath_(hapPath), runtimeExtractor_(runtimeExtractor)
|
||||
{}
|
||||
~JsModuleReader() = default;
|
||||
@ -41,7 +41,7 @@ public:
|
||||
|
||||
private:
|
||||
std::string hapPath_;
|
||||
std::shared_ptr<BaseExtractor> runtimeExtractor_;
|
||||
std::shared_ptr<RuntimeExtractor> runtimeExtractor_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <regex>
|
||||
|
||||
#include "ability_constants.h"
|
||||
#include "base_extractor.h"
|
||||
#include "connect_server_manager.h"
|
||||
#include "event_handler.h"
|
||||
#include "file_path_utils.h"
|
||||
@ -39,6 +38,7 @@
|
||||
#include "js_worker.h"
|
||||
#include "native_engine/impl/ark/ark_native_engine.h"
|
||||
#include "parameters.h"
|
||||
#include "runtime_extractor.h"
|
||||
#include "systemcapability.h"
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
@ -117,9 +117,9 @@ public:
|
||||
bool result = false;
|
||||
if (isBundle_ && !hapPath.empty()) {
|
||||
std::ostringstream outStream;
|
||||
std::shared_ptr<BaseExtractor> runtimeExtractor;
|
||||
std::shared_ptr<RuntimeExtractor> runtimeExtractor;
|
||||
if (runtimeExtractorMap_.find(hapPath) == runtimeExtractorMap_.end()) {
|
||||
runtimeExtractor = BaseExtractor::Create(hapPath);
|
||||
runtimeExtractor = RuntimeExtractor::Create(hapPath);
|
||||
runtimeExtractor->SetRuntimeFlag(true);
|
||||
runtimeExtractorMap_.insert(make_pair(hapPath, runtimeExtractor));
|
||||
} else {
|
||||
@ -166,7 +166,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
AbilityRuntime::BaseExtractor extractor(hqfFile);
|
||||
AbilityRuntime::RuntimeExtractor extractor(hqfFile);
|
||||
if (!extractor.Init()) {
|
||||
HILOG_ERROR("Extractor of %{private}s init failed.", hqfFile.c_str());
|
||||
return;
|
||||
@ -260,7 +260,7 @@ private:
|
||||
if (!options.preload) {
|
||||
bundleName_ = options.bundleName;
|
||||
panda::JSNApi::SetHostResolvePathTracker(vm_, JsModuleSearcher(options.bundleName));
|
||||
std::shared_ptr<BaseExtractor> runtimeExtractor = BaseExtractor::Create(options.hapPath);
|
||||
std::shared_ptr<RuntimeExtractor> runtimeExtractor = RuntimeExtractor::Create(options.hapPath);
|
||||
runtimeExtractor->SetRuntimeFlag(true);
|
||||
runtimeExtractorMap_.insert(make_pair(options.hapPath, runtimeExtractor));
|
||||
panda::JSNApi::SetHostResolveBufferTracker(
|
||||
@ -612,9 +612,9 @@ bool JsRuntime::RunScript(const std::string& srcPath, const std::string& hapPath
|
||||
bool result = false;
|
||||
if (isBundle_ && !hapPath.empty()) {
|
||||
std::ostringstream outStream;
|
||||
std::shared_ptr<BaseExtractor> runtimeExtractor;
|
||||
std::shared_ptr<RuntimeExtractor> runtimeExtractor;
|
||||
if (runtimeExtractorMap_.find(hapPath) == runtimeExtractorMap_.end()) {
|
||||
runtimeExtractor = BaseExtractor::Create(hapPath);
|
||||
runtimeExtractor = RuntimeExtractor::Create(hapPath);
|
||||
runtimeExtractor->SetRuntimeFlag(true);
|
||||
runtimeExtractorMap_.insert(make_pair(hapPath, runtimeExtractor));
|
||||
} else {
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_BASE_EXTRACTOR_H
|
||||
#define OHOS_ABILITY_RUNTIME_BASE_EXTRACTOR_H
|
||||
#ifndef OHOS_ABILITY_RUNTIME_RUNTIME_EXTRACTOR_H
|
||||
#define OHOS_ABILITY_RUNTIME_RUNTIME_EXTRACTOR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -22,11 +22,11 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class BaseExtractor {
|
||||
class RuntimeExtractor {
|
||||
public:
|
||||
explicit BaseExtractor(const std::string &source);
|
||||
virtual ~BaseExtractor();
|
||||
static std::shared_ptr<BaseExtractor> Create(const std::string& hapPath);
|
||||
explicit RuntimeExtractor(const std::string &source);
|
||||
virtual ~RuntimeExtractor();
|
||||
static std::shared_ptr<RuntimeExtractor> Create(const std::string& hapPath);
|
||||
|
||||
/**
|
||||
* @brief Open compressed file.
|
||||
@ -80,4 +80,4 @@ private:
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_BASE_EXTRACTOR_H
|
||||
#endif // OHOS_ABILITY_RUNTIME_RUNTIME_EXTRACTOR_H
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base_extractor.h"
|
||||
#include "runtime_extractor.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <regex>
|
||||
@ -26,15 +26,15 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
BaseExtractor::BaseExtractor(const std::string &source) : sourceFile_(source), zipFile_(source)
|
||||
RuntimeExtractor::RuntimeExtractor(const std::string &source) : sourceFile_(source), zipFile_(source)
|
||||
{
|
||||
hapPath_ = source;
|
||||
}
|
||||
|
||||
BaseExtractor::~BaseExtractor()
|
||||
RuntimeExtractor::~RuntimeExtractor()
|
||||
{}
|
||||
|
||||
bool BaseExtractor::Init()
|
||||
bool RuntimeExtractor::Init()
|
||||
{
|
||||
if (!zipFile_.Open()) {
|
||||
HILOG_ERROR("open zip file failed");
|
||||
@ -45,11 +45,11 @@ bool BaseExtractor::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<BaseExtractor> BaseExtractor::Create(const std::string& hapPath)
|
||||
std::shared_ptr<RuntimeExtractor> RuntimeExtractor::Create(const std::string& hapPath)
|
||||
{
|
||||
if (hapPath.empty()) {
|
||||
HILOG_ERROR("source is nullptr");
|
||||
return std::shared_ptr<BaseExtractor>();
|
||||
return std::shared_ptr<RuntimeExtractor>();
|
||||
}
|
||||
|
||||
std::string loadPath;
|
||||
@ -58,16 +58,16 @@ std::shared_ptr<BaseExtractor> BaseExtractor::Create(const std::string& hapPath)
|
||||
} else {
|
||||
loadPath = hapPath;
|
||||
}
|
||||
std::shared_ptr<BaseExtractor> baseExtractor = std::make_shared<BaseExtractor>(loadPath);
|
||||
if (!baseExtractor->Init()) {
|
||||
HILOG_ERROR("BaseExtractor create failed");
|
||||
return std::shared_ptr<BaseExtractor>();
|
||||
std::shared_ptr<RuntimeExtractor> runtimeExtractor = std::make_shared<RuntimeExtractor>(loadPath);
|
||||
if (!runtimeExtractor->Init()) {
|
||||
HILOG_ERROR("RuntimeExtractor create failed");
|
||||
return std::shared_ptr<RuntimeExtractor>();
|
||||
}
|
||||
|
||||
return baseExtractor;
|
||||
return runtimeExtractor;
|
||||
}
|
||||
|
||||
bool BaseExtractor::GetFileBuffer(const std::string& srcPath, std::ostringstream& dest)
|
||||
bool RuntimeExtractor::GetFileBuffer(const std::string& srcPath, std::ostringstream& dest)
|
||||
{
|
||||
if (!initial_) {
|
||||
HILOG_ERROR("extractor is not initial");
|
||||
@ -88,7 +88,7 @@ bool BaseExtractor::GetFileBuffer(const std::string& srcPath, std::ostringstream
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BaseExtractor::GetFileList(const std::string& srcPath, std::vector<std::string>& assetList)
|
||||
bool RuntimeExtractor::GetFileList(const std::string& srcPath, std::vector<std::string>& assetList)
|
||||
{
|
||||
if (!initial_) {
|
||||
HILOG_ERROR("extractor is not initial");
|
||||
@ -120,7 +120,7 @@ bool BaseExtractor::GetFileList(const std::string& srcPath, std::vector<std::str
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BaseExtractor::HasEntry(const std::string &fileName) const
|
||||
bool RuntimeExtractor::HasEntry(const std::string &fileName) const
|
||||
{
|
||||
if (!initial_) {
|
||||
HILOG_ERROR("extractor is not initial");
|
||||
@ -130,7 +130,7 @@ bool BaseExtractor::HasEntry(const std::string &fileName) const
|
||||
return zipFile_.HasEntry(fileName);
|
||||
}
|
||||
|
||||
bool BaseExtractor::IsDirExist(const std::string &dir) const
|
||||
bool RuntimeExtractor::IsDirExist(const std::string &dir) const
|
||||
{
|
||||
if (!initial_) {
|
||||
HILOG_ERROR("extractor is not initial");
|
||||
@ -143,7 +143,7 @@ bool BaseExtractor::IsDirExist(const std::string &dir) const
|
||||
return zipFile_.IsDirExist(dir);
|
||||
}
|
||||
|
||||
bool BaseExtractor::ExtractByName(const std::string &fileName, std::ostream &dest) const
|
||||
bool RuntimeExtractor::ExtractByName(const std::string &fileName, std::ostream &dest) const
|
||||
{
|
||||
if (!initial_) {
|
||||
HILOG_ERROR("extractor is not initial");
|
||||
@ -156,7 +156,7 @@ bool BaseExtractor::ExtractByName(const std::string &fileName, std::ostream &des
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BaseExtractor::ExtractFile(const std::string &fileName, const std::string &targetPath) const
|
||||
bool RuntimeExtractor::ExtractFile(const std::string &fileName, const std::string &targetPath) const
|
||||
{
|
||||
std::ofstream fileStream;
|
||||
fileStream.open(targetPath, std::ios_base::out | std::ios_base::binary);
|
||||
@ -178,7 +178,7 @@ bool BaseExtractor::ExtractFile(const std::string &fileName, const std::string &
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BaseExtractor::GetZipFileNames(std::vector<std::string> &fileNames)
|
||||
bool RuntimeExtractor::GetZipFileNames(std::vector<std::string> &fileNames)
|
||||
{
|
||||
auto &entryMap = zipFile_.GetAllEntries();
|
||||
for (auto &entry : entryMap) {
|
||||
@ -187,7 +187,7 @@ bool BaseExtractor::GetZipFileNames(std::vector<std::string> &fileNames)
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseExtractor::GetSpecifiedTypeFiles(std::vector<std::string> &fileNames, const std::string &suffix)
|
||||
void RuntimeExtractor::GetSpecifiedTypeFiles(std::vector<std::string> &fileNames, const std::string &suffix)
|
||||
{
|
||||
auto &entryMap = zipFile_.GetAllEntries();
|
||||
for (auto &entry : entryMap) {
|
||||
@ -203,7 +203,7 @@ void BaseExtractor::GetSpecifiedTypeFiles(std::vector<std::string> &fileNames, c
|
||||
return;
|
||||
}
|
||||
|
||||
bool BaseExtractor::IsStageBasedModel(std::string abilityName)
|
||||
bool RuntimeExtractor::IsStageBasedModel(std::string abilityName)
|
||||
{
|
||||
auto &entryMap = zipFile_.GetAllEntries();
|
||||
std::vector<std::string> splitStrs;
|
||||
@ -214,12 +214,12 @@ bool BaseExtractor::IsStageBasedModel(std::string abilityName)
|
||||
return isStageBasedModel;
|
||||
}
|
||||
|
||||
bool BaseExtractor::IsSameHap(const std::string& hapPath) const
|
||||
bool RuntimeExtractor::IsSameHap(const std::string& hapPath) const
|
||||
{
|
||||
return !hapPath_.empty() && !hapPath.empty() && hapPath_ == hapPath;
|
||||
}
|
||||
|
||||
void BaseExtractor::SetRuntimeFlag(bool isRuntime)
|
||||
void RuntimeExtractor::SetRuntimeFlag(bool isRuntime)
|
||||
{
|
||||
zipFile_.SetIsRuntime(isRuntime);
|
||||
}
|
@ -32,7 +32,7 @@ class EventHandler;
|
||||
} // namespace AppExecFwk
|
||||
namespace AbilityRuntime {
|
||||
class TimerTask;
|
||||
class BaseExtractor;
|
||||
class RuntimeExtractor;
|
||||
|
||||
void *DetachCallbackFunc(NativeEngine *engine, void *value, void *hint);
|
||||
|
||||
@ -87,7 +87,7 @@ protected:
|
||||
std::unique_ptr<NativeReference> methodRequireNapiRef_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> eventHandler_;
|
||||
std::unordered_map<std::string, NativeReference*> modules_;
|
||||
std::map<std::string, std::shared_ptr<BaseExtractor>> runtimeExtractorMap_;
|
||||
std::map<std::string, std::shared_ptr<RuntimeExtractor>> runtimeExtractorMap_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user