mirror of
https://gitee.com/openharmony/filemanagement_user_file_service
synced 2024-11-27 01:21:32 +00:00
commit
ff77dd6d80
@ -29,8 +29,10 @@ void NAPI_application_FileAccessExtensionAbility_AutoRegister()
|
|||||||
.name = "application.FileAccessExtensionAbility",
|
.name = "application.FileAccessExtensionAbility",
|
||||||
.fileName = "application/libfileaccessextensionability_napi.so/FileAccessExtensionAbility.js",
|
.fileName = "application/libfileaccessextensionability_napi.so/FileAccessExtensionAbility.js",
|
||||||
};
|
};
|
||||||
|
if (moduleManager != nullptr) {
|
||||||
moduleManager->Register(&newModuleInfo);
|
moduleManager->Register(&newModuleInfo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" __attribute__((visibility("default")))
|
extern "C" __attribute__((visibility("default")))
|
||||||
void NAPI_application_FileAccessExtensionAbility_GetJSCode(const char **buf, int *bufLen)
|
void NAPI_application_FileAccessExtensionAbility_GetJSCode(const char **buf, int *bufLen)
|
||||||
|
@ -1302,6 +1302,10 @@ napi_value NAPI_UnregisterObserver(napi_env env, napi_callback_info info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto wrapper = observerWrapper.release();
|
auto wrapper = observerWrapper.release();
|
||||||
|
if (wrapper == nullptr) {
|
||||||
|
HILOG_ERROR("wrapper is nullptr");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
retCode = fileAccessHelper->UnregisterNotify(uri, wrapper->callback);
|
retCode = fileAccessHelper->UnregisterNotify(uri, wrapper->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +74,19 @@ static napi_status SetValueArray(const napi_env& env,
|
|||||||
void NapiObserver::NapiWorkScope(uv_work_t *work, int status)
|
void NapiObserver::NapiWorkScope(uv_work_t *work, int status)
|
||||||
{
|
{
|
||||||
if (work == nullptr) {
|
if (work == nullptr) {
|
||||||
HILOG_ERROR("Work is null");
|
HILOG_ERROR("Work is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::unique_ptr<CallbackParam> param(reinterpret_cast<CallbackParam *>(work->data));
|
std::unique_ptr<CallbackParam> param(reinterpret_cast<CallbackParam *>(work->data));
|
||||||
napi_handle_scope scope = nullptr;
|
napi_handle_scope scope = nullptr;
|
||||||
|
if (param == nullptr) {
|
||||||
|
HILOG_ERROR("Param is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (param->napiObserver == nullptr) {
|
||||||
|
HILOG_ERROR("param->napiObserver is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
napi_open_handle_scope(param->napiObserver->env_, &scope);
|
napi_open_handle_scope(param->napiObserver->env_, &scope);
|
||||||
if (scope == nullptr) {
|
if (scope == nullptr) {
|
||||||
HILOG_ERROR("napi_open_handle_scope failed");
|
HILOG_ERROR("napi_open_handle_scope failed");
|
||||||
|
@ -54,6 +54,10 @@ static napi_value Init(napi_env env, napi_value exports)
|
|||||||
products.emplace_back(std::make_unique<NapiFileIteratorExporter>(env, exports));
|
products.emplace_back(std::make_unique<NapiFileIteratorExporter>(env, exports));
|
||||||
products.emplace_back(std::make_unique<NapiFileInfoExporter>(env, exports));
|
products.emplace_back(std::make_unique<NapiFileInfoExporter>(env, exports));
|
||||||
for (auto &&product : products) {
|
for (auto &&product : products) {
|
||||||
|
if (product == nullptr) {
|
||||||
|
HILOG_ERROR("INNER BUG. product is nullptr");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
if (!product->Export()) {
|
if (!product->Export()) {
|
||||||
HILOG_ERROR("INNER BUG. Failed to export class %{public}s", product->GetClassName().c_str());
|
HILOG_ERROR("INNER BUG. Failed to export class %{public}s", product->GetClassName().c_str());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -98,6 +98,10 @@ static int TransferListFile(const RootInfoEntity* rootEntity, FileIteratorEntity
|
|||||||
fileIteratorEntity->offset = 0;
|
fileIteratorEntity->offset = 0;
|
||||||
fileIteratorEntity->filter = std::move(filter);
|
fileIteratorEntity->filter = std::move(filter);
|
||||||
fileIteratorEntity->flag = CALL_LISTFILE;
|
fileIteratorEntity->flag = CALL_LISTFILE;
|
||||||
|
if (rootEntity->fileAccessHelper == nullptr) {
|
||||||
|
HILOG_ERROR("rootEntity->fileAccessHelper is nullptr");
|
||||||
|
return E_GETRESULT;
|
||||||
|
}
|
||||||
return rootEntity->fileAccessHelper->ListFile(fileInfo, fileIteratorEntity->offset, filter,
|
return rootEntity->fileAccessHelper->ListFile(fileInfo, fileIteratorEntity->offset, filter,
|
||||||
fileIteratorEntity->memInfo);
|
fileIteratorEntity->memInfo);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,10 @@ int FileAccessExtProxy::OpenFile(const Uri &uri, const int flags, int &fd)
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("OpenFile");
|
trace.Start("OpenFile");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -82,6 +86,10 @@ int FileAccessExtProxy::CreateFile(const Uri &parent, const std::string &display
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("CreateFile");
|
trace.Start("CreateFile");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -136,6 +144,10 @@ int FileAccessExtProxy::Mkdir(const Uri &parent, const std::string &displayName,
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("Mkdir");
|
trace.Start("Mkdir");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -190,6 +202,10 @@ int FileAccessExtProxy::Delete(const Uri &sourceFile)
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("Delete");
|
trace.Start("Delete");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -227,6 +243,10 @@ int FileAccessExtProxy::Move(const Uri &sourceFile, const Uri &targetParent, Uri
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("Move");
|
trace.Start("Move");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -359,6 +379,10 @@ int FileAccessExtProxy::Copy(const Uri &sourceUri, const Uri &destUri, std::vect
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("Copy");
|
trace.Start("Copy");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -392,6 +416,10 @@ int FileAccessExtProxy::CopyFile(const Uri &sourceUri, const Uri &destUri, const
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("CopyFile");
|
trace.Start("CopyFile");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -437,6 +465,10 @@ int FileAccessExtProxy::Rename(const Uri &sourceFile, const std::string &display
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("Rename");
|
trace.Start("Rename");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -577,6 +609,10 @@ int FileAccessExtProxy::ListFile(const FileInfo &fileInfo, const int64_t offset,
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("ListFile");
|
trace.Start("ListFile");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -618,6 +654,10 @@ int FileAccessExtProxy::ScanFile(const FileInfo &fileInfo, const int64_t offset,
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("ScanFile");
|
trace.Start("ScanFile");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -691,6 +731,10 @@ int FileAccessExtProxy::Query(const Uri &uri, std::vector<std::string> &columns,
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("Query");
|
trace.Start("Query");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -738,6 +782,10 @@ int FileAccessExtProxy::GetRoots(std::vector<RootInfo> &rootInfoVec)
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("GetRoots");
|
trace.Start("GetRoots");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -784,6 +832,10 @@ int FileAccessExtProxy::GetFileInfoFromUri(const Uri &selectFile, FileInfo &file
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("GetFileInfoFromUri");
|
trace.Start("GetFileInfoFromUri");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -828,6 +880,10 @@ int FileAccessExtProxy::GetFileInfoFromRelativePath(const std::string &selectFil
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("GetFileInfoFromRelativePath");
|
trace.Start("GetFileInfoFromRelativePath");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -872,6 +928,10 @@ int FileAccessExtProxy::Access(const Uri &uri, bool &isExist)
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("Access");
|
trace.Start("Access");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -914,6 +974,10 @@ int FileAccessExtProxy::StartWatcher(const Uri &uri)
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("StartWatcher");
|
trace.Start("StartWatcher");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -952,6 +1016,10 @@ int FileAccessExtProxy::StopWatcher(const Uri &uri)
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("StopWatcher");
|
trace.Start("StopWatcher");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
@ -1028,6 +1096,10 @@ int FileAccessExtProxy::MoveItem(const Uri &sourceFile, const Uri &targetParent,
|
|||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("MoveItem");
|
trace.Start("MoveItem");
|
||||||
|
if (Remote() == nullptr) {
|
||||||
|
HILOG_ERROR("Remote is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||||
HILOG_ERROR("WriteInterfaceToken failed");
|
HILOG_ERROR("WriteInterfaceToken failed");
|
||||||
|
@ -362,6 +362,10 @@ bool FileAccessHelper::GetProxy()
|
|||||||
{
|
{
|
||||||
for (auto iter = cMap_.begin(); iter != cMap_.end(); ++iter) {
|
for (auto iter = cMap_.begin(); iter != cMap_.end(); ++iter) {
|
||||||
auto connectInfo = iter->second;
|
auto connectInfo = iter->second;
|
||||||
|
if (connectInfo == nullptr || connectInfo->fileAccessExtConnection == nullptr) {
|
||||||
|
HILOG_ERROR("connectInfo is nullptr");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!connectInfo->fileAccessExtConnection->IsExtAbilityConnected()) {
|
if (!connectInfo->fileAccessExtConnection->IsExtAbilityConnected()) {
|
||||||
connectInfo->fileAccessExtConnection->ConnectFileExtAbility(connectInfo->want);
|
connectInfo->fileAccessExtConnection->ConnectFileExtAbility(connectInfo->want);
|
||||||
}
|
}
|
||||||
@ -909,6 +913,10 @@ int FileAccessHelper::GetRoots(std::vector<RootInfo> &rootInfoVec)
|
|||||||
int ret = ERR_OK;
|
int ret = ERR_OK;
|
||||||
for (auto iter = cMap_.begin(); iter != cMap_.end(); ++iter) {
|
for (auto iter = cMap_.begin(); iter != cMap_.end(); ++iter) {
|
||||||
auto connectInfo = iter->second;
|
auto connectInfo = iter->second;
|
||||||
|
if (connectInfo == nullptr || connectInfo->fileAccessExtConnection == nullptr) {
|
||||||
|
HILOG_ERROR("connectInfo is nullptr");
|
||||||
|
return E_IPCS;
|
||||||
|
}
|
||||||
auto fileAccessExtProxy = connectInfo->fileAccessExtConnection->GetFileExtProxy();
|
auto fileAccessExtProxy = connectInfo->fileAccessExtConnection->GetFileExtProxy();
|
||||||
std::vector<RootInfo> results;
|
std::vector<RootInfo> results;
|
||||||
if (!fileAccessExtProxy) {
|
if (!fileAccessExtProxy) {
|
||||||
|
@ -84,11 +84,13 @@ void JsFileAccessExtAbility::Init(const std::shared_ptr<AbilityLocalRecord> &rec
|
|||||||
HILOG_ERROR("Failed to get srcPath");
|
HILOG_ERROR("Failed to get srcPath");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (abilityInfo_ == nullptr) {
|
||||||
|
HILOG_ERROR("abilityInfo_ is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::string moduleName(Extension::abilityInfo_->moduleName);
|
std::string moduleName(Extension::abilityInfo_->moduleName);
|
||||||
moduleName.append("::").append(abilityInfo_->name);
|
moduleName.append("::").append(abilityInfo_->name);
|
||||||
HandleScope handleScope(jsRuntime_);
|
HandleScope handleScope(jsRuntime_);
|
||||||
|
|
||||||
jsObj_ = jsRuntime_.LoadModule(moduleName, srcPath, abilityInfo_->hapPath,
|
jsObj_ = jsRuntime_.LoadModule(moduleName, srcPath, abilityInfo_->hapPath,
|
||||||
abilityInfo_->compileMode == AbilityRuntime::CompileMode::ES_MODULE);
|
abilityInfo_->compileMode == AbilityRuntime::CompileMode::ES_MODULE);
|
||||||
if (jsObj_ == nullptr) {
|
if (jsObj_ == nullptr) {
|
||||||
@ -242,7 +244,7 @@ int JsFileAccessExtAbility::CallJsMethod(const std::string &funcName, JsRuntime
|
|||||||
loop, work.get(), [](uv_work_t *work) {},
|
loop, work.get(), [](uv_work_t *work) {},
|
||||||
[](uv_work_t *work, int status) {
|
[](uv_work_t *work, int status) {
|
||||||
CallJsParam *param = reinterpret_cast<CallJsParam *>(work->data);
|
CallJsParam *param = reinterpret_cast<CallJsParam *>(work->data);
|
||||||
if (param == nullptr) {
|
if (param == nullptr || param->jsRuntime == nullptr) {
|
||||||
HILOG_ERROR("failed to get CallJsParam.");
|
HILOG_ERROR("failed to get CallJsParam.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1194,7 +1196,7 @@ void ChangeCurrentDir(RootInfo &rootInfo)
|
|||||||
HILOG_WARN("get userName fail");
|
HILOG_WARN("get userName fail");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HILOG_DEBUG("GetuserName: %{public}s", userName.c_str());
|
HILOG_DEBUG("GetuserName: %{private}s", userName.c_str());
|
||||||
if (rootInfo.uri.rfind("file://docs/storage/Users/currentUser") == 0) {
|
if (rootInfo.uri.rfind("file://docs/storage/Users/currentUser") == 0) {
|
||||||
rootInfo.uri = "file://docs/storage/Users/" + userName;
|
rootInfo.uri = "file://docs/storage/Users/" + userName;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,10 @@ static napi_value Export(napi_env env, napi_value exports)
|
|||||||
std::vector<unique_ptr<NExporter>> products;
|
std::vector<unique_ptr<NExporter>> products;
|
||||||
products.emplace_back(make_unique<RecentNExporter>(env, exports));
|
products.emplace_back(make_unique<RecentNExporter>(env, exports));
|
||||||
for (auto &&product : products) {
|
for (auto &&product : products) {
|
||||||
|
if (!product) {
|
||||||
|
HILOG_ERROR("product is nullptr");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
if (!product->Export()) {
|
if (!product->Export()) {
|
||||||
HILOG_ERROR("INNER BUG. Failed to export class %{public}s for module recent",
|
HILOG_ERROR("INNER BUG. Failed to export class %{public}s for module recent",
|
||||||
product->GetClassName().c_str());
|
product->GetClassName().c_str());
|
||||||
|
@ -159,7 +159,15 @@ napi_value RecentNExporter::RemoveRecentFile(napi_env env, napi_callback_info cb
|
|||||||
|
|
||||||
static void Deleter(struct NameListArg *arg)
|
static void Deleter(struct NameListArg *arg)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < arg->direntNum; i++) {
|
if (arg == nullptr) {
|
||||||
|
HILOG_ERROR("invalid argument arg is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (arg->namelist == nullptr) {
|
||||||
|
HILOG_ERROR("arg->namelist is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (uint32_t i = 0; i < arg->direntNum; i++) {
|
||||||
free((arg->namelist)[i]);
|
free((arg->namelist)[i]);
|
||||||
(arg->namelist)[i] = nullptr;
|
(arg->namelist)[i] = nullptr;
|
||||||
}
|
}
|
||||||
@ -195,6 +203,10 @@ static int SortReceneFile(const struct dirent **a, const struct dirent **b)
|
|||||||
|
|
||||||
static int FilterFunc(const struct dirent *filename)
|
static int FilterFunc(const struct dirent *filename)
|
||||||
{
|
{
|
||||||
|
if (filename == nullptr) {
|
||||||
|
HILOGE("filename is bullptr");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (string_view(filename->d_name) == "." || string_view(filename->d_name) == "..") {
|
if (string_view(filename->d_name) == "." || string_view(filename->d_name) == "..") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -254,7 +266,7 @@ static napi_value GetListFileResult(napi_env env, struct NameListArg* pNameList)
|
|||||||
}
|
}
|
||||||
auto buf = CreateUniquePtr<char[]>(BUF_SIZE);
|
auto buf = CreateUniquePtr<char[]>(BUF_SIZE);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < pNameList->direntNum; ++i) {
|
for (uint32_t i = 0; i < pNameList->direntNum; ++i) {
|
||||||
string recentFilePath = RecentNExporter::recentPath_ + string((*(pNameList->namelist[i])).d_name);
|
string recentFilePath = RecentNExporter::recentPath_ + string((*(pNameList->namelist[i])).d_name);
|
||||||
if (index < MAX_RECENT_SIZE) {
|
if (index < MAX_RECENT_SIZE) {
|
||||||
auto [checkRealFileRes, realFileStatBuf] = CheckRealFileExist(recentFilePath);
|
auto [checkRealFileRes, realFileStatBuf] = CheckRealFileExist(recentFilePath);
|
||||||
|
@ -31,6 +31,10 @@ static napi_value Export(napi_env env, napi_value exports)
|
|||||||
products.emplace_back(make_unique<FileTrashNExporter>(env, exports));
|
products.emplace_back(make_unique<FileTrashNExporter>(env, exports));
|
||||||
|
|
||||||
for (auto &&product : products) {
|
for (auto &&product : products) {
|
||||||
|
if (!product) {
|
||||||
|
HILOG_ERROR("product is nullptr");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
string nExporterName = product->GetClassName();
|
string nExporterName = product->GetClassName();
|
||||||
if (!product->Export()) {
|
if (!product->Export()) {
|
||||||
HILOG_ERROR("INNER BUG. Failed to export class %{public}s for module trash", nExporterName.c_str());
|
HILOG_ERROR("INNER BUG. Failed to export class %{public}s for module trash", nExporterName.c_str());
|
||||||
|
@ -96,7 +96,7 @@ static string GetTimeSlotFromPath(const string &path)
|
|||||||
// 获取时间戳目录位置
|
// 获取时间戳目录位置
|
||||||
size_t trashPathWithTimePrefixPos = realFilePathWithTime.find_first_of("/");
|
size_t trashPathWithTimePrefixPos = realFilePathWithTime.find_first_of("/");
|
||||||
if (trashPathWithTimePrefixPos == string::npos) {
|
if (trashPathWithTimePrefixPos == string::npos) {
|
||||||
HILOG_ERROR("GetTimeSlotFromPath: Invalid path = %{public}s", path.c_str());
|
HILOG_ERROR("GetTimeSlotFromPath: Invalid path = %{private}s", path.c_str());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
string timeSlot = realFilePathWithTime.substr(0, trashPathWithTimePrefixPos);
|
string timeSlot = realFilePathWithTime.substr(0, trashPathWithTimePrefixPos);
|
||||||
@ -111,7 +111,7 @@ static int RecursiveFunc(const string &path, vector<string> &dirents)
|
|||||||
HILOG_ERROR("Failed to request heap memory.");
|
HILOG_ERROR("Failed to request heap memory.");
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
HILOG_DEBUG("RecursiveFunc: scandir path = %{public}s", path.c_str());
|
HILOG_DEBUG("RecursiveFunc: scandir path = %{private}s", path.c_str());
|
||||||
int num = scandir(path.c_str(), &(pNameList->namelist), FilterFunc, alphasort);
|
int num = scandir(path.c_str(), &(pNameList->namelist), FilterFunc, alphasort);
|
||||||
if (num < 0) {
|
if (num < 0) {
|
||||||
HILOG_ERROR("RecursiveFunc: Failed to scan dir");
|
HILOG_ERROR("RecursiveFunc: Failed to scan dir");
|
||||||
@ -119,14 +119,18 @@ static int RecursiveFunc(const string &path, vector<string> &dirents)
|
|||||||
}
|
}
|
||||||
pNameList->direntNum = num;
|
pNameList->direntNum = num;
|
||||||
string pathInRecur = path;
|
string pathInRecur = path;
|
||||||
for (int i = 0; i < num; i++) {
|
for (uint32_t i = 0; i < num; i++) {
|
||||||
|
if (!pNameList->namelist) {
|
||||||
|
HILOG_ERROR("pNameList->namelist is nullptr.");
|
||||||
|
return ENOMEM;
|
||||||
|
}
|
||||||
if ((*(pNameList->namelist[i])).d_type == DT_REG) {
|
if ((*(pNameList->namelist[i])).d_type == DT_REG) {
|
||||||
dirents.emplace_back(path + '/' + pNameList->namelist[i]->d_name);
|
dirents.emplace_back(path + '/' + pNameList->namelist[i]->d_name);
|
||||||
} else if ((*(pNameList->namelist[i])).d_type == DT_DIR) {
|
} else if ((*(pNameList->namelist[i])).d_type == DT_DIR) {
|
||||||
string pathTemp = pathInRecur;
|
string pathTemp = pathInRecur;
|
||||||
pathInRecur += '/' + string((*(pNameList->namelist[i])).d_name);
|
pathInRecur += '/' + string((*(pNameList->namelist[i])).d_name);
|
||||||
// check if path include TRASH_SUB_DIR + "/", need to add it into dirents
|
// check if path include TRASH_SUB_DIR + "/", need to add it into dirents
|
||||||
HILOG_DEBUG("RecursiveFunc: pathTemp = %{public}s", pathTemp.c_str());
|
HILOG_DEBUG("RecursiveFunc: pathTemp = %{private}s", pathTemp.c_str());
|
||||||
string timeSlot = GetTimeSlotFromPath(pathTemp);
|
string timeSlot = GetTimeSlotFromPath(pathTemp);
|
||||||
if (!timeSlot.empty() && pathInRecur.rfind(TRASH_SUB_DIR + timeSlot + "/") != string::npos) {
|
if (!timeSlot.empty() && pathInRecur.rfind(TRASH_SUB_DIR + timeSlot + "/") != string::npos) {
|
||||||
// Only filter previous dir is TRASH_SUB_DIR
|
// Only filter previous dir is TRASH_SUB_DIR
|
||||||
@ -219,7 +223,7 @@ static string FindSourceFilePath(const string &path)
|
|||||||
|
|
||||||
static bool Mkdirs(const string &path, bool isDir, string &newRecoveredPath)
|
static bool Mkdirs(const string &path, bool isDir, string &newRecoveredPath)
|
||||||
{
|
{
|
||||||
HILOG_INFO("Mkdirs: path = %{public}s", path.c_str());
|
HILOG_INFO("Mkdirs: path = %{private}s", path.c_str());
|
||||||
string recoveredPath = path;
|
string recoveredPath = path;
|
||||||
string folderName = "";
|
string folderName = "";
|
||||||
size_t lastPos = 0;
|
size_t lastPos = 0;
|
||||||
@ -240,7 +244,7 @@ static bool Mkdirs(const string &path, bool isDir, string &newRecoveredPath)
|
|||||||
lastPos = i;
|
lastPos = i;
|
||||||
auto [isExist, ret] = Access(recoveredPath);
|
auto [isExist, ret] = Access(recoveredPath);
|
||||||
if (!isExist && !Mkdir(recoveredPath)) {
|
if (!isExist && !Mkdir(recoveredPath)) {
|
||||||
HILOG_ERROR("Mkdirs fail for %{public}s ", recoveredPath.c_str());
|
HILOG_ERROR("Mkdirs fail for %{private}s ", recoveredPath.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
recoveredPath[i] = '/';
|
recoveredPath[i] = '/';
|
||||||
@ -318,14 +322,14 @@ static int MoveFile(const string &srcFile, const string &destFile)
|
|||||||
|
|
||||||
static string RecurCheckIfOnlyContentInDir(const string &path, size_t trashWithTimePos, const string &trashWithTimePath)
|
static string RecurCheckIfOnlyContentInDir(const string &path, size_t trashWithTimePos, const string &trashWithTimePath)
|
||||||
{
|
{
|
||||||
HILOG_INFO("RecurCheckIfOnlyContentInDir: path = %{public}s", path.c_str());
|
HILOG_INFO("RecurCheckIfOnlyContentInDir: path = %{private}s", path.c_str());
|
||||||
size_t slashPos = path.find_last_of("/");
|
size_t slashPos = path.find_last_of("/");
|
||||||
if (slashPos <= trashWithTimePos) {
|
if (slashPos <= trashWithTimePos) {
|
||||||
HILOG_DEBUG("RecurCheckIfOnlyContentInDir: slashPos = %{public}zu", slashPos);
|
HILOG_DEBUG("RecurCheckIfOnlyContentInDir: slashPos = %{public}zu", slashPos);
|
||||||
return trashWithTimePath;
|
return trashWithTimePath;
|
||||||
}
|
}
|
||||||
string parentPath = path.substr(0, slashPos);
|
string parentPath = path.substr(0, slashPos);
|
||||||
HILOG_DEBUG("RecurCheckIfOnlyContentInDir: parentPath = %{public}s", parentPath.c_str());
|
HILOG_DEBUG("RecurCheckIfOnlyContentInDir: parentPath = %{private}s", parentPath.c_str());
|
||||||
int num = ScanDir(parentPath);
|
int num = ScanDir(parentPath);
|
||||||
HILOG_DEBUG("RecurCheckIfOnlyContentInDir: num = %{public}d", num);
|
HILOG_DEBUG("RecurCheckIfOnlyContentInDir: num = %{public}d", num);
|
||||||
if (num > 1) {
|
if (num > 1) {
|
||||||
@ -336,14 +340,14 @@ static string RecurCheckIfOnlyContentInDir(const string &path, size_t trashWithT
|
|||||||
// 需要向上一层目录判断
|
// 需要向上一层目录判断
|
||||||
return RecurCheckIfOnlyContentInDir(parentPath, trashWithTimePos, trashWithTimePath);
|
return RecurCheckIfOnlyContentInDir(parentPath, trashWithTimePos, trashWithTimePath);
|
||||||
} else {
|
} else {
|
||||||
HILOG_ERROR("RecurCheckIfOnlyContentInDir: invalid path = %{public}s", path.c_str());
|
HILOG_ERROR("RecurCheckIfOnlyContentInDir: invalid path = %{private}s", path.c_str());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string GetToDeletePath(const string &toDeletePath, napi_env env)
|
static string GetToDeletePath(const string &toDeletePath, napi_env env)
|
||||||
{
|
{
|
||||||
HILOG_INFO("GetToDeletePath: toDeletePath = %{public}s", toDeletePath.c_str());
|
HILOG_INFO("GetToDeletePath: toDeletePath = %{private}s", toDeletePath.c_str());
|
||||||
// 判断是否为有效回收站路径
|
// 判断是否为有效回收站路径
|
||||||
size_t slashSize = 1;
|
size_t slashSize = 1;
|
||||||
// 获取/Trash目录位置
|
// 获取/Trash目录位置
|
||||||
@ -459,7 +463,7 @@ napi_value FileTrashNExporter::ListFile(napi_env env, napi_callback_info info)
|
|||||||
static napi_value RecoverFile(napi_env env, const string &filePath)
|
static napi_value RecoverFile(napi_env env, const string &filePath)
|
||||||
{
|
{
|
||||||
string sourceFilePath = FindSourceFilePath(filePath);
|
string sourceFilePath = FindSourceFilePath(filePath);
|
||||||
HILOG_INFO("RecoverFile: sourceFilePath = %{public}s", sourceFilePath.c_str());
|
HILOG_INFO("RecoverFile: sourceFilePath = %{private}s", sourceFilePath.c_str());
|
||||||
string newDestPath = sourceFilePath;
|
string newDestPath = sourceFilePath;
|
||||||
if (newDestPath.length() == 0 || !Mkdirs(sourceFilePath, false, newDestPath)) {
|
if (newDestPath.length() == 0 || !Mkdirs(sourceFilePath, false, newDestPath)) {
|
||||||
HILOG_ERROR("RecoverFile: Mkdirs failed");
|
HILOG_ERROR("RecoverFile: Mkdirs failed");
|
||||||
@ -494,9 +498,9 @@ static int RecoverFilePart(vector<string> filePathList, map<string, string> dirP
|
|||||||
// 处理文件
|
// 处理文件
|
||||||
for (size_t j = 0; j < filePathList.size(); j++) {
|
for (size_t j = 0; j < filePathList.size(); j++) {
|
||||||
string filePath = filePathList[j];
|
string filePath = filePathList[j];
|
||||||
HILOG_INFO("RecoverFilePart: filePath = %{public}s", filePath.c_str());
|
HILOG_INFO("RecoverFilePart: filePath = %{private}s", filePath.c_str());
|
||||||
string sourceFilePath = FindSourceFilePath(filePath);
|
string sourceFilePath = FindSourceFilePath(filePath);
|
||||||
HILOG_INFO("RecoverFilePart: sourceFilePath = %{public}s", sourceFilePath.c_str());
|
HILOG_INFO("RecoverFilePart: sourceFilePath = %{private}s", sourceFilePath.c_str());
|
||||||
|
|
||||||
size_t lastSlashPos = sourceFilePath.find_last_of("/");
|
size_t lastSlashPos = sourceFilePath.find_last_of("/");
|
||||||
string fileName = sourceFilePath.substr(lastSlashPos + 1);
|
string fileName = sourceFilePath.substr(lastSlashPos + 1);
|
||||||
@ -519,10 +523,10 @@ static map<string, string> MakeAndFindUpdateNameDir(vector<string> filterDirPath
|
|||||||
for (size_t j = 0; j < filterDirPathList.size(); j++) {
|
for (size_t j = 0; j < filterDirPathList.size(); j++) {
|
||||||
string dirPath = filterDirPathList[j];
|
string dirPath = filterDirPathList[j];
|
||||||
string sourceFilePath = FindSourceFilePath(dirPath);
|
string sourceFilePath = FindSourceFilePath(dirPath);
|
||||||
HILOG_DEBUG("MakeAndFindUpdateNameDir: sourceFilePath = %{public}s", sourceFilePath.c_str());
|
HILOG_DEBUG("MakeAndFindUpdateNameDir: sourceFilePath = %{private}s", sourceFilePath.c_str());
|
||||||
string newDestPath = sourceFilePath;
|
string newDestPath = sourceFilePath;
|
||||||
if (Mkdirs(sourceFilePath, true, newDestPath)) {
|
if (Mkdirs(sourceFilePath, true, newDestPath)) {
|
||||||
HILOG_DEBUG("MakeAndFindUpdateNameDir: newDestPath = %{public}s", newDestPath.c_str());
|
HILOG_DEBUG("MakeAndFindUpdateNameDir: newDestPath = %{private}s", newDestPath.c_str());
|
||||||
if (newDestPath != sourceFilePath) {
|
if (newDestPath != sourceFilePath) {
|
||||||
dirPath2UpdatedNameMap.insert(make_pair(sourceFilePath, newDestPath));
|
dirPath2UpdatedNameMap.insert(make_pair(sourceFilePath, newDestPath));
|
||||||
}
|
}
|
||||||
@ -600,7 +604,7 @@ napi_value FileTrashNExporter::Recover(napi_env env, napi_callback_info info)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
string uriStr = uriPtr.get();
|
string uriStr = uriPtr.get();
|
||||||
HILOG_DEBUG("Recover: uriPtr.get() = %{public}s", uriStr.c_str());
|
HILOG_DEBUG("Recover: uriPtr.get() = %{private}s", uriStr.c_str());
|
||||||
|
|
||||||
// 获取沙箱目录地址
|
// 获取沙箱目录地址
|
||||||
AppFileService::ModuleFileUri::FileUri fileUri(uriStr);
|
AppFileService::ModuleFileUri::FileUri fileUri(uriStr);
|
||||||
@ -611,12 +615,12 @@ napi_value FileTrashNExporter::Recover(napi_env env, napi_callback_info info)
|
|||||||
HILOG_ERROR("Recover: Invalid Path");
|
HILOG_ERROR("Recover: Invalid Path");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
HILOG_DEBUG("Recover: path = %{public}s", path.c_str());
|
HILOG_DEBUG("Recover: path = %{private}s", path.c_str());
|
||||||
|
|
||||||
// 判断是否是回收站路径
|
// 判断是否是回收站路径
|
||||||
if (path.find(FileTrashNExporter::trashPath_) == string::npos) {
|
if (path.find(FileTrashNExporter::trashPath_) == string::npos) {
|
||||||
NError(EINVAL).ThrowErr(env);
|
NError(EINVAL).ThrowErr(env);
|
||||||
HILOG_ERROR("Recover: path = %{public}s is not Trash path", path.c_str());
|
HILOG_ERROR("Recover: path = %{private}s is not Trash path", path.c_str());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,7 +661,7 @@ napi_value FileTrashNExporter::CompletelyDelete(napi_env env, napi_callback_info
|
|||||||
}
|
}
|
||||||
|
|
||||||
string uriStr = uriPtr.get();
|
string uriStr = uriPtr.get();
|
||||||
HILOG_DEBUG("Recover: uriPtr.get() = %{public}s", uriStr.c_str());
|
HILOG_DEBUG("Recover: uriPtr.get() = %{private}s", uriStr.c_str());
|
||||||
|
|
||||||
// 获取沙箱目录地址
|
// 获取沙箱目录地址
|
||||||
AppFileService::ModuleFileUri::FileUri fileUri(uriStr);
|
AppFileService::ModuleFileUri::FileUri fileUri(uriStr);
|
||||||
@ -668,12 +672,12 @@ napi_value FileTrashNExporter::CompletelyDelete(napi_env env, napi_callback_info
|
|||||||
HILOG_ERROR("Recover: Invalid Path");
|
HILOG_ERROR("Recover: Invalid Path");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
HILOG_DEBUG("Recover: path = %{public}s", path.c_str());
|
HILOG_DEBUG("Recover: path = %{private}s", path.c_str());
|
||||||
|
|
||||||
// 判断是否是回收站路径
|
// 判断是否是回收站路径
|
||||||
if (path.find(FileTrashNExporter::trashPath_) == string::npos) {
|
if (path.find(FileTrashNExporter::trashPath_) == string::npos) {
|
||||||
NError(EINVAL).ThrowErr(env);
|
NError(EINVAL).ThrowErr(env);
|
||||||
HILOG_ERROR("Recover: path = %{public}s is not Trash path", path.c_str());
|
HILOG_ERROR("Recover: path = %{private}s is not Trash path", path.c_str());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -723,7 +727,7 @@ void FileTrashNExporter::InitTrashPath()
|
|||||||
FileTrashNExporter::trashPath_ = "/storage/Users/" + userName + "/.Trash";
|
FileTrashNExporter::trashPath_ = "/storage/Users/" + userName + "/.Trash";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HILOG_INFO("GetRecentDir %{public}s", FileTrashNExporter::trashPath_.c_str());
|
HILOG_INFO("GetRecentDir %{private}s", FileTrashNExporter::trashPath_.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,10 @@ void ModalUICallback::SetSessionId(int32_t sessionId)
|
|||||||
void ModalUICallback::OnRelease(int32_t releaseCode)
|
void ModalUICallback::OnRelease(int32_t releaseCode)
|
||||||
{
|
{
|
||||||
HILOG_INFO("[picker] OnRelease enter. release code is %{public}d", releaseCode);
|
HILOG_INFO("[picker] OnRelease enter. release code is %{public}d", releaseCode);
|
||||||
|
if (!pickerCallBack_) {
|
||||||
|
HILOG_ERROR("[picker] OnRelease error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
this->uiContent->CloseModalUIExtension(this->sessionId_);
|
this->uiContent->CloseModalUIExtension(this->sessionId_);
|
||||||
pickerCallBack_->ready = true;
|
pickerCallBack_->ready = true;
|
||||||
}
|
}
|
||||||
@ -48,6 +52,10 @@ void ModalUICallback::OnError(int32_t code, const std::string& name, const std::
|
|||||||
void ModalUICallback::OnResultForModal(int32_t resultCode, const OHOS::AAFwk::Want &result)
|
void ModalUICallback::OnResultForModal(int32_t resultCode, const OHOS::AAFwk::Want &result)
|
||||||
{
|
{
|
||||||
HILOG_INFO("[picker] OnResultForModal enter. resultCode is %{public}d,", resultCode);
|
HILOG_INFO("[picker] OnResultForModal enter. resultCode is %{public}d,", resultCode);
|
||||||
|
if (!pickerCallBack_) {
|
||||||
|
HILOG_ERROR("[picker] OnResultForModal error.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
pickerCallBack_->resultCode = resultCode;
|
pickerCallBack_->resultCode = resultCode;
|
||||||
pickerCallBack_->want = result;
|
pickerCallBack_->want = result;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,14 @@ static void StartModalPickerExecute(napi_env env, void *data)
|
|||||||
{
|
{
|
||||||
HILOG_INFO("[picker]: StartModalPickerExecute begin");
|
HILOG_INFO("[picker]: StartModalPickerExecute begin");
|
||||||
auto *context = static_cast<PickerAsyncContext*>(data);
|
auto *context = static_cast<PickerAsyncContext*>(data);
|
||||||
|
if (!context) {
|
||||||
|
HILOG_ERROR("[picker]:context is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!context->pickerCallBack) {
|
||||||
|
HILOG_ERROR("[picker]:!context->pickerCallBack is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
while (!context->pickerCallBack->ready) {
|
while (!context->pickerCallBack->ready) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME_MS));
|
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_TIME_MS));
|
||||||
}
|
}
|
||||||
@ -60,6 +68,10 @@ static void StartModalPickerExecute(napi_env env, void *data)
|
|||||||
static void MakeResultWithArr(napi_env env, std::string key, napi_value &result,
|
static void MakeResultWithArr(napi_env env, std::string key, napi_value &result,
|
||||||
std::shared_ptr<PickerCallBack> pickerCallBack)
|
std::shared_ptr<PickerCallBack> pickerCallBack)
|
||||||
{
|
{
|
||||||
|
if (pickerCallBack == nullptr) {
|
||||||
|
HILOG_ERROR("[picker]:pickerCallBack is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
napi_value array;
|
napi_value array;
|
||||||
napi_create_array(env, &array);
|
napi_create_array(env, &array);
|
||||||
napi_status status = napi_generic_failure;
|
napi_status status = napi_generic_failure;
|
||||||
@ -87,6 +99,10 @@ static void MakeResultWithArr(napi_env env, std::string key, napi_value &result,
|
|||||||
static void MakeResultWithInt(napi_env env, std::string key, napi_value &result,
|
static void MakeResultWithInt(napi_env env, std::string key, napi_value &result,
|
||||||
std::shared_ptr<PickerCallBack> pickerCallBack)
|
std::shared_ptr<PickerCallBack> pickerCallBack)
|
||||||
{
|
{
|
||||||
|
if (pickerCallBack == nullptr) {
|
||||||
|
HILOG_ERROR("[picker]: pickerCallBack is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
napi_status status = napi_generic_failure;
|
napi_status status = napi_generic_failure;
|
||||||
if (pickerCallBack->want.GetParams().HasParam(key.c_str())) {
|
if (pickerCallBack->want.GetParams().HasParam(key.c_str())) {
|
||||||
const int32_t suffixindex = pickerCallBack->want.GetIntParam(key.c_str(), -1);
|
const int32_t suffixindex = pickerCallBack->want.GetIntParam(key.c_str(), -1);
|
||||||
@ -103,6 +119,10 @@ static void MakeResultWithInt(napi_env env, std::string key, napi_value &result,
|
|||||||
static void MakeResultWithBool(napi_env env, std::string key, napi_value &result,
|
static void MakeResultWithBool(napi_env env, std::string key, napi_value &result,
|
||||||
std::shared_ptr<PickerCallBack> pickerCallBack)
|
std::shared_ptr<PickerCallBack> pickerCallBack)
|
||||||
{
|
{
|
||||||
|
if (pickerCallBack == nullptr) {
|
||||||
|
HILOG_ERROR("[picker]: pickerCallBack is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
napi_status status = napi_generic_failure;
|
napi_status status = napi_generic_failure;
|
||||||
if (pickerCallBack->want.GetParams().HasParam(key.c_str())) {
|
if (pickerCallBack->want.GetParams().HasParam(key.c_str())) {
|
||||||
const bool boolVal = pickerCallBack->want.GetBoolParam(key.c_str(), false);
|
const bool boolVal = pickerCallBack->want.GetBoolParam(key.c_str(), false);
|
||||||
@ -119,7 +139,7 @@ static void MakeResultWithBool(napi_env env, std::string key, napi_value &result
|
|||||||
static napi_value MakeResultWithPickerCallBack(napi_env env, std::shared_ptr<PickerCallBack> pickerCallBack)
|
static napi_value MakeResultWithPickerCallBack(napi_env env, std::shared_ptr<PickerCallBack> pickerCallBack)
|
||||||
{
|
{
|
||||||
if (pickerCallBack == nullptr) {
|
if (pickerCallBack == nullptr) {
|
||||||
HILOG_ERROR("pickerCallBack is null");
|
HILOG_ERROR("[picker]: pickerCallBack is null");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
napi_value result = nullptr;
|
napi_value result = nullptr;
|
||||||
@ -227,6 +247,10 @@ static ErrCode GetCustomShowingWindow(napi_env env, AsyncContext &asyncContext,
|
|||||||
const napi_callback_info info, sptr<Rosen::Window> &window)
|
const napi_callback_info info, sptr<Rosen::Window> &window)
|
||||||
{
|
{
|
||||||
HILOG_INFO("[picker] GetCustomShowingWindow enter.");
|
HILOG_INFO("[picker] GetCustomShowingWindow enter.");
|
||||||
|
if (!asyncContext) {
|
||||||
|
HILOG_ERROR("[picker] asyncContext is nullptr.");
|
||||||
|
return ERR_INV;
|
||||||
|
}
|
||||||
napi_status status;
|
napi_status status;
|
||||||
if (!IsTypeRight(env, asyncContext->argv[ARGS_TWO], napi_object)) {
|
if (!IsTypeRight(env, asyncContext->argv[ARGS_TWO], napi_object)) {
|
||||||
HILOG_ERROR("[picker] The type of the parameter transferred to the window is not object.");
|
HILOG_ERROR("[picker] The type of the parameter transferred to the window is not object.");
|
||||||
@ -255,6 +279,10 @@ static ErrCode GetCustomShowingWindow(napi_env env, AsyncContext &asyncContext,
|
|||||||
Ace::UIContent *GetUIContent(napi_env env, napi_callback_info info,
|
Ace::UIContent *GetUIContent(napi_env env, napi_callback_info info,
|
||||||
unique_ptr<PickerAsyncContext> &AsyncContext)
|
unique_ptr<PickerAsyncContext> &AsyncContext)
|
||||||
{
|
{
|
||||||
|
if (!AsyncContext) {
|
||||||
|
HILOG_ERROR("[picker] asyncContext is nullptr.");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
bool isStageMode = false;
|
bool isStageMode = false;
|
||||||
napi_status status = AbilityRuntime::IsStageContext(env, AsyncContext->argv[ARGS_ZERO], isStageMode);
|
napi_status status = AbilityRuntime::IsStageContext(env, AsyncContext->argv[ARGS_ZERO], isStageMode);
|
||||||
if (status != napi_ok || !isStageMode) {
|
if (status != napi_ok || !isStageMode) {
|
||||||
@ -334,6 +362,10 @@ static napi_status AsyncContextSetStaticObjectInfo(napi_env env, napi_callback_i
|
|||||||
AsyncContext &asyncContext, const size_t minArgs, const size_t maxArgs)
|
AsyncContext &asyncContext, const size_t minArgs, const size_t maxArgs)
|
||||||
{
|
{
|
||||||
HILOG_INFO("[picker]: AsyncContextSetStaticObjectInfo begin.");
|
HILOG_INFO("[picker]: AsyncContextSetStaticObjectInfo begin.");
|
||||||
|
if (!asyncContext) {
|
||||||
|
HILOG_ERROR("[picker] asyncContext is nullptr.");
|
||||||
|
return napi_invalid_arg;
|
||||||
|
}
|
||||||
napi_value thisVar = nullptr;
|
napi_value thisVar = nullptr;
|
||||||
asyncContext->argc = maxArgs;
|
asyncContext->argc = maxArgs;
|
||||||
napi_status ret = napi_get_cb_info(env, info, &asyncContext->argc, &(asyncContext->argv[ARGS_ZERO]),
|
napi_status ret = napi_get_cb_info(env, info, &asyncContext->argc, &(asyncContext->argv[ARGS_ZERO]),
|
||||||
|
@ -71,6 +71,9 @@ void FileAccessService::OnStart()
|
|||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("OnStart");
|
trace.Start("OnStart");
|
||||||
sptr<FileAccessService> service = FileAccessService::GetInstance();
|
sptr<FileAccessService> service = FileAccessService::GetInstance();
|
||||||
|
if (service == nullptr) {
|
||||||
|
HILOG_ERROR("service is nullptr");
|
||||||
|
}
|
||||||
service->Init();
|
service->Init();
|
||||||
if (!Publish(service)) {
|
if (!Publish(service)) {
|
||||||
HILOG_ERROR("OnStart register to system ability manager failed");
|
HILOG_ERROR("OnStart register to system ability manager failed");
|
||||||
@ -249,6 +252,10 @@ void FileAccessService::ObserverDeathRecipient::OnRemoteDied(const wptr<IRemoteO
|
|||||||
void FileAccessService::CleanRelativeObserver(const sptr<IFileAccessObserver> &observer)
|
void FileAccessService::CleanRelativeObserver(const sptr<IFileAccessObserver> &observer)
|
||||||
{
|
{
|
||||||
shared_ptr<ObserverContext> obsContext = make_shared<ObserverContext>(observer);
|
shared_ptr<ObserverContext> obsContext = make_shared<ObserverContext>(observer);
|
||||||
|
if (obsContext == nullptr) {
|
||||||
|
HILOG_ERROR("obsContext is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint32_t code = obsManager_.getId([obsContext](const shared_ptr<ObserverContext> &afterContext) {
|
uint32_t code = obsManager_.getId([obsContext](const shared_ptr<ObserverContext> &afterContext) {
|
||||||
return obsContext->EqualTo(afterContext);
|
return obsContext->EqualTo(afterContext);
|
||||||
});
|
});
|
||||||
@ -306,7 +313,7 @@ int32_t FileAccessService::OperateObsNode(Uri &uri, bool notifyForDescendants, u
|
|||||||
const std::shared_ptr<ConnectExtensionInfo> &info)
|
const std::shared_ptr<ConnectExtensionInfo> &info)
|
||||||
{
|
{
|
||||||
string uriStr = uri.ToString();
|
string uriStr = uri.ToString();
|
||||||
HILOG_INFO("OperateObsNode uriStr: %{public}s", uriStr.c_str());
|
HILOG_INFO("OperateObsNode uriStr: %{private}s", uriStr.c_str());
|
||||||
{
|
{
|
||||||
lock_guard<mutex> lock(nodeMutex_);
|
lock_guard<mutex> lock(nodeMutex_);
|
||||||
auto iter = relationshipMap_.find(uriStr);
|
auto iter = relationshipMap_.find(uriStr);
|
||||||
@ -409,7 +416,7 @@ void FileAccessService::RemoveRelations(string &uriStr, shared_ptr<ObserverNode>
|
|||||||
|
|
||||||
int FileAccessService::FindUri(const string &uriStr, shared_ptr<ObserverNode> &outObsNode)
|
int FileAccessService::FindUri(const string &uriStr, shared_ptr<ObserverNode> &outObsNode)
|
||||||
{
|
{
|
||||||
HILOG_INFO("uriStr: %{public}s", uriStr.c_str());
|
HILOG_INFO("uriStr: %{private}s", uriStr.c_str());
|
||||||
lock_guard<mutex> lock(nodeMutex_);
|
lock_guard<mutex> lock(nodeMutex_);
|
||||||
HILOG_DEBUG("FindUri start");
|
HILOG_DEBUG("FindUri start");
|
||||||
auto iter = relationshipMap_.find(uriStr);
|
auto iter = relationshipMap_.find(uriStr);
|
||||||
@ -783,6 +790,10 @@ void FileAccessService::AddAppProxy(const sptr<AAFwk::IAbilityConnection>& conne
|
|||||||
HILOG_INFO("sa had proxy,needn't create connection");
|
HILOG_INFO("sa had proxy,needn't create connection");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (connection->AsObject() == nullptr) {
|
||||||
|
HILOG_ERROR("connection->AsObject() is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
connection->AsObject()->AddDeathRecipient(appDeathRecipient_);
|
connection->AsObject()->AddDeathRecipient(appDeathRecipient_);
|
||||||
appProxyMap_[key] = value;
|
appProxyMap_[key] = value;
|
||||||
appConnection_[key] = connection;
|
appConnection_[key] = connection;
|
||||||
|
@ -52,7 +52,11 @@ static void Deleter(struct NameListArg *arg)
|
|||||||
HILOG_ERROR("invalid argument");
|
HILOG_ERROR("invalid argument");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < arg->direntNum; i++) {
|
if (arg->namelist == nullptr) {
|
||||||
|
HILOG_ERROR("arg->namelist is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (uint32_t i = 0; i < arg->direntNum; i++) {
|
||||||
free((arg->namelist)[i]);
|
free((arg->namelist)[i]);
|
||||||
(arg->namelist)[i] = nullptr;
|
(arg->namelist)[i] = nullptr;
|
||||||
}
|
}
|
||||||
@ -274,7 +278,7 @@ static int ScanDir(const string &path)
|
|||||||
HILOG_ERROR("Failed to request heap memory.");
|
HILOG_ERROR("Failed to request heap memory.");
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
HILOG_INFO("RecursiveFunc: scandir path = %{public}s", path.c_str());
|
HILOG_INFO("RecursiveFunc: scandir path = %{private}s", path.c_str());
|
||||||
return scandir(path.c_str(), &(pNameList->namelist), FilterFunc, alphasort);
|
return scandir(path.c_str(), &(pNameList->namelist), FilterFunc, alphasort);
|
||||||
}
|
}
|
||||||
} // OHOS::FileManagement
|
} // OHOS::FileManagement
|
Loading…
Reference in New Issue
Block a user