mirror of
https://gitee.com/openharmony/filemanagement_user_file_service
synced 2024-11-22 23:10:15 +00:00
commit
ff77dd6d80
@ -29,7 +29,9 @@ void NAPI_application_FileAccessExtensionAbility_AutoRegister()
|
||||
.name = "application.FileAccessExtensionAbility",
|
||||
.fileName = "application/libfileaccessextensionability_napi.so/FileAccessExtensionAbility.js",
|
||||
};
|
||||
moduleManager->Register(&newModuleInfo);
|
||||
if (moduleManager != nullptr) {
|
||||
moduleManager->Register(&newModuleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __attribute__((visibility("default")))
|
||||
|
@ -1302,6 +1302,10 @@ napi_value NAPI_UnregisterObserver(napi_env env, napi_callback_info info)
|
||||
}
|
||||
|
||||
auto wrapper = observerWrapper.release();
|
||||
if (wrapper == nullptr) {
|
||||
HILOG_ERROR("wrapper is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (work == nullptr) {
|
||||
HILOG_ERROR("Work is null");
|
||||
HILOG_ERROR("Work is nullptr");
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<CallbackParam> param(reinterpret_cast<CallbackParam *>(work->data));
|
||||
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);
|
||||
if (scope == nullptr) {
|
||||
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<NapiFileInfoExporter>(env, exports));
|
||||
for (auto &&product : products) {
|
||||
if (product == nullptr) {
|
||||
HILOG_ERROR("INNER BUG. product is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
if (!product->Export()) {
|
||||
HILOG_ERROR("INNER BUG. Failed to export class %{public}s", product->GetClassName().c_str());
|
||||
return nullptr;
|
||||
|
@ -98,6 +98,10 @@ static int TransferListFile(const RootInfoEntity* rootEntity, FileIteratorEntity
|
||||
fileIteratorEntity->offset = 0;
|
||||
fileIteratorEntity->filter = std::move(filter);
|
||||
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,
|
||||
fileIteratorEntity->memInfo);
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ int FileAccessExtProxy::OpenFile(const Uri &uri, const int flags, int &fd)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("OpenFile");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -82,6 +86,10 @@ int FileAccessExtProxy::CreateFile(const Uri &parent, const std::string &display
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CreateFile");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -136,6 +144,10 @@ int FileAccessExtProxy::Mkdir(const Uri &parent, const std::string &displayName,
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("Mkdir");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -190,6 +202,10 @@ int FileAccessExtProxy::Delete(const Uri &sourceFile)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("Delete");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -227,6 +243,10 @@ int FileAccessExtProxy::Move(const Uri &sourceFile, const Uri &targetParent, Uri
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("Move");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -359,6 +379,10 @@ int FileAccessExtProxy::Copy(const Uri &sourceUri, const Uri &destUri, std::vect
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("Copy");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -392,6 +416,10 @@ int FileAccessExtProxy::CopyFile(const Uri &sourceUri, const Uri &destUri, const
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CopyFile");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -437,6 +465,10 @@ int FileAccessExtProxy::Rename(const Uri &sourceFile, const std::string &display
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("Rename");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -577,6 +609,10 @@ int FileAccessExtProxy::ListFile(const FileInfo &fileInfo, const int64_t offset,
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("ListFile");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -618,6 +654,10 @@ int FileAccessExtProxy::ScanFile(const FileInfo &fileInfo, const int64_t offset,
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("ScanFile");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -691,6 +731,10 @@ int FileAccessExtProxy::Query(const Uri &uri, std::vector<std::string> &columns,
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("Query");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -738,6 +782,10 @@ int FileAccessExtProxy::GetRoots(std::vector<RootInfo> &rootInfoVec)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("GetRoots");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -784,6 +832,10 @@ int FileAccessExtProxy::GetFileInfoFromUri(const Uri &selectFile, FileInfo &file
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("GetFileInfoFromUri");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -828,6 +880,10 @@ int FileAccessExtProxy::GetFileInfoFromRelativePath(const std::string &selectFil
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("GetFileInfoFromRelativePath");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -872,6 +928,10 @@ int FileAccessExtProxy::Access(const Uri &uri, bool &isExist)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("Access");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -914,6 +974,10 @@ int FileAccessExtProxy::StartWatcher(const Uri &uri)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("StartWatcher");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -952,6 +1016,10 @@ int FileAccessExtProxy::StopWatcher(const Uri &uri)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("StopWatcher");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
@ -1028,6 +1096,10 @@ int FileAccessExtProxy::MoveItem(const Uri &sourceFile, const Uri &targetParent,
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("MoveItem");
|
||||
if (Remote() == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(FileAccessExtProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
|
@ -362,6 +362,10 @@ bool FileAccessHelper::GetProxy()
|
||||
{
|
||||
for (auto iter = cMap_.begin(); iter != cMap_.end(); ++iter) {
|
||||
auto connectInfo = iter->second;
|
||||
if (connectInfo == nullptr || connectInfo->fileAccessExtConnection == nullptr) {
|
||||
HILOG_ERROR("connectInfo is nullptr");
|
||||
return false;
|
||||
}
|
||||
if (!connectInfo->fileAccessExtConnection->IsExtAbilityConnected()) {
|
||||
connectInfo->fileAccessExtConnection->ConnectFileExtAbility(connectInfo->want);
|
||||
}
|
||||
@ -909,6 +913,10 @@ int FileAccessHelper::GetRoots(std::vector<RootInfo> &rootInfoVec)
|
||||
int ret = ERR_OK;
|
||||
for (auto iter = cMap_.begin(); iter != cMap_.end(); ++iter) {
|
||||
auto connectInfo = iter->second;
|
||||
if (connectInfo == nullptr || connectInfo->fileAccessExtConnection == nullptr) {
|
||||
HILOG_ERROR("connectInfo is nullptr");
|
||||
return E_IPCS;
|
||||
}
|
||||
auto fileAccessExtProxy = connectInfo->fileAccessExtConnection->GetFileExtProxy();
|
||||
std::vector<RootInfo> results;
|
||||
if (!fileAccessExtProxy) {
|
||||
|
@ -84,11 +84,13 @@ void JsFileAccessExtAbility::Init(const std::shared_ptr<AbilityLocalRecord> &rec
|
||||
HILOG_ERROR("Failed to get srcPath");
|
||||
return;
|
||||
}
|
||||
|
||||
if (abilityInfo_ == nullptr) {
|
||||
HILOG_ERROR("abilityInfo_ is nullptr");
|
||||
return;
|
||||
}
|
||||
std::string moduleName(Extension::abilityInfo_->moduleName);
|
||||
moduleName.append("::").append(abilityInfo_->name);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
|
||||
jsObj_ = jsRuntime_.LoadModule(moduleName, srcPath, abilityInfo_->hapPath,
|
||||
abilityInfo_->compileMode == AbilityRuntime::CompileMode::ES_MODULE);
|
||||
if (jsObj_ == nullptr) {
|
||||
@ -242,7 +244,7 @@ int JsFileAccessExtAbility::CallJsMethod(const std::string &funcName, JsRuntime
|
||||
loop, work.get(), [](uv_work_t *work) {},
|
||||
[](uv_work_t *work, int status) {
|
||||
CallJsParam *param = reinterpret_cast<CallJsParam *>(work->data);
|
||||
if (param == nullptr) {
|
||||
if (param == nullptr || param->jsRuntime == nullptr) {
|
||||
HILOG_ERROR("failed to get CallJsParam.");
|
||||
return;
|
||||
}
|
||||
@ -1194,7 +1196,7 @@ void ChangeCurrentDir(RootInfo &rootInfo)
|
||||
HILOG_WARN("get userName fail");
|
||||
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) {
|
||||
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;
|
||||
products.emplace_back(make_unique<RecentNExporter>(env, exports));
|
||||
for (auto &&product : products) {
|
||||
if (!product) {
|
||||
HILOG_ERROR("product is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
if (!product->Export()) {
|
||||
HILOG_ERROR("INNER BUG. Failed to export class %{public}s for module recent",
|
||||
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)
|
||||
{
|
||||
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]);
|
||||
(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)
|
||||
{
|
||||
if (filename == nullptr) {
|
||||
HILOGE("filename is bullptr");
|
||||
return false;
|
||||
}
|
||||
if (string_view(filename->d_name) == "." || string_view(filename->d_name) == "..") {
|
||||
return false;
|
||||
}
|
||||
@ -254,7 +266,7 @@ static napi_value GetListFileResult(napi_env env, struct NameListArg* pNameList)
|
||||
}
|
||||
auto buf = CreateUniquePtr<char[]>(BUF_SIZE);
|
||||
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);
|
||||
if (index < MAX_RECENT_SIZE) {
|
||||
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));
|
||||
|
||||
for (auto &&product : products) {
|
||||
if (!product) {
|
||||
HILOG_ERROR("product is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
string nExporterName = product->GetClassName();
|
||||
if (!product->Export()) {
|
||||
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("/");
|
||||
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 "";
|
||||
}
|
||||
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.");
|
||||
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);
|
||||
if (num < 0) {
|
||||
HILOG_ERROR("RecursiveFunc: Failed to scan dir");
|
||||
@ -119,14 +119,18 @@ static int RecursiveFunc(const string &path, vector<string> &dirents)
|
||||
}
|
||||
pNameList->direntNum = num;
|
||||
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) {
|
||||
dirents.emplace_back(path + '/' + pNameList->namelist[i]->d_name);
|
||||
} else if ((*(pNameList->namelist[i])).d_type == DT_DIR) {
|
||||
string pathTemp = pathInRecur;
|
||||
pathInRecur += '/' + string((*(pNameList->namelist[i])).d_name);
|
||||
// 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);
|
||||
if (!timeSlot.empty() && pathInRecur.rfind(TRASH_SUB_DIR + timeSlot + "/") != string::npos) {
|
||||
// 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)
|
||||
{
|
||||
HILOG_INFO("Mkdirs: path = %{public}s", path.c_str());
|
||||
HILOG_INFO("Mkdirs: path = %{private}s", path.c_str());
|
||||
string recoveredPath = path;
|
||||
string folderName = "";
|
||||
size_t lastPos = 0;
|
||||
@ -240,7 +244,7 @@ static bool Mkdirs(const string &path, bool isDir, string &newRecoveredPath)
|
||||
lastPos = i;
|
||||
auto [isExist, ret] = Access(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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
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("/");
|
||||
if (slashPos <= trashWithTimePos) {
|
||||
HILOG_DEBUG("RecurCheckIfOnlyContentInDir: slashPos = %{public}zu", slashPos);
|
||||
return trashWithTimePath;
|
||||
}
|
||||
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);
|
||||
HILOG_DEBUG("RecurCheckIfOnlyContentInDir: num = %{public}d", num);
|
||||
if (num > 1) {
|
||||
@ -336,14 +340,14 @@ static string RecurCheckIfOnlyContentInDir(const string &path, size_t trashWithT
|
||||
// 需要向上一层目录判断
|
||||
return RecurCheckIfOnlyContentInDir(parentPath, trashWithTimePos, trashWithTimePath);
|
||||
} else {
|
||||
HILOG_ERROR("RecurCheckIfOnlyContentInDir: invalid path = %{public}s", path.c_str());
|
||||
HILOG_ERROR("RecurCheckIfOnlyContentInDir: invalid path = %{private}s", path.c_str());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
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;
|
||||
// 获取/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)
|
||||
{
|
||||
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;
|
||||
if (newDestPath.length() == 0 || !Mkdirs(sourceFilePath, false, newDestPath)) {
|
||||
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++) {
|
||||
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);
|
||||
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("/");
|
||||
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++) {
|
||||
string dirPath = filterDirPathList[j];
|
||||
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;
|
||||
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) {
|
||||
dirPath2UpdatedNameMap.insert(make_pair(sourceFilePath, newDestPath));
|
||||
}
|
||||
@ -600,7 +604,7 @@ napi_value FileTrashNExporter::Recover(napi_env env, napi_callback_info info)
|
||||
return nullptr;
|
||||
}
|
||||
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);
|
||||
@ -611,12 +615,12 @@ napi_value FileTrashNExporter::Recover(napi_env env, napi_callback_info info)
|
||||
HILOG_ERROR("Recover: Invalid Path");
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -657,7 +661,7 @@ napi_value FileTrashNExporter::CompletelyDelete(napi_env env, napi_callback_info
|
||||
}
|
||||
|
||||
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);
|
||||
@ -668,12 +672,12 @@ napi_value FileTrashNExporter::CompletelyDelete(napi_env env, napi_callback_info
|
||||
HILOG_ERROR("Recover: Invalid Path");
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -723,7 +727,7 @@ void FileTrashNExporter::InitTrashPath()
|
||||
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)
|
||||
{
|
||||
HILOG_INFO("[picker] OnRelease enter. release code is %{public}d", releaseCode);
|
||||
if (!pickerCallBack_) {
|
||||
HILOG_ERROR("[picker] OnRelease error");
|
||||
return;
|
||||
}
|
||||
this->uiContent->CloseModalUIExtension(this->sessionId_);
|
||||
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)
|
||||
{
|
||||
HILOG_INFO("[picker] OnResultForModal enter. resultCode is %{public}d,", resultCode);
|
||||
if (!pickerCallBack_) {
|
||||
HILOG_ERROR("[picker] OnResultForModal error.");
|
||||
return;
|
||||
}
|
||||
pickerCallBack_->resultCode = resultCode;
|
||||
pickerCallBack_->want = result;
|
||||
}
|
||||
|
@ -51,6 +51,14 @@ static void StartModalPickerExecute(napi_env env, void *data)
|
||||
{
|
||||
HILOG_INFO("[picker]: StartModalPickerExecute begin");
|
||||
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) {
|
||||
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,
|
||||
std::shared_ptr<PickerCallBack> pickerCallBack)
|
||||
{
|
||||
if (pickerCallBack == nullptr) {
|
||||
HILOG_ERROR("[picker]:pickerCallBack is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_value array;
|
||||
napi_create_array(env, &array);
|
||||
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,
|
||||
std::shared_ptr<PickerCallBack> pickerCallBack)
|
||||
{
|
||||
if (pickerCallBack == nullptr) {
|
||||
HILOG_ERROR("[picker]: pickerCallBack is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_status status = napi_generic_failure;
|
||||
if (pickerCallBack->want.GetParams().HasParam(key.c_str())) {
|
||||
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,
|
||||
std::shared_ptr<PickerCallBack> pickerCallBack)
|
||||
{
|
||||
if (pickerCallBack == nullptr) {
|
||||
HILOG_ERROR("[picker]: pickerCallBack is nullptr");
|
||||
return;
|
||||
}
|
||||
napi_status status = napi_generic_failure;
|
||||
if (pickerCallBack->want.GetParams().HasParam(key.c_str())) {
|
||||
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)
|
||||
{
|
||||
if (pickerCallBack == nullptr) {
|
||||
HILOG_ERROR("pickerCallBack is null");
|
||||
HILOG_ERROR("[picker]: pickerCallBack is null");
|
||||
return 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)
|
||||
{
|
||||
HILOG_INFO("[picker] GetCustomShowingWindow enter.");
|
||||
if (!asyncContext) {
|
||||
HILOG_ERROR("[picker] asyncContext is nullptr.");
|
||||
return ERR_INV;
|
||||
}
|
||||
napi_status status;
|
||||
if (!IsTypeRight(env, asyncContext->argv[ARGS_TWO], napi_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,
|
||||
unique_ptr<PickerAsyncContext> &AsyncContext)
|
||||
{
|
||||
if (!AsyncContext) {
|
||||
HILOG_ERROR("[picker] asyncContext is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
bool isStageMode = false;
|
||||
napi_status status = AbilityRuntime::IsStageContext(env, AsyncContext->argv[ARGS_ZERO], 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)
|
||||
{
|
||||
HILOG_INFO("[picker]: AsyncContextSetStaticObjectInfo begin.");
|
||||
if (!asyncContext) {
|
||||
HILOG_ERROR("[picker] asyncContext is nullptr.");
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
napi_value thisVar = nullptr;
|
||||
asyncContext->argc = maxArgs;
|
||||
napi_status ret = napi_get_cb_info(env, info, &asyncContext->argc, &(asyncContext->argv[ARGS_ZERO]),
|
||||
|
@ -71,6 +71,9 @@ void FileAccessService::OnStart()
|
||||
UserAccessTracer trace;
|
||||
trace.Start("OnStart");
|
||||
sptr<FileAccessService> service = FileAccessService::GetInstance();
|
||||
if (service == nullptr) {
|
||||
HILOG_ERROR("service is nullptr");
|
||||
}
|
||||
service->Init();
|
||||
if (!Publish(service)) {
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
return obsContext->EqualTo(afterContext);
|
||||
});
|
||||
@ -306,7 +313,7 @@ int32_t FileAccessService::OperateObsNode(Uri &uri, bool notifyForDescendants, u
|
||||
const std::shared_ptr<ConnectExtensionInfo> &info)
|
||||
{
|
||||
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_);
|
||||
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)
|
||||
{
|
||||
HILOG_INFO("uriStr: %{public}s", uriStr.c_str());
|
||||
HILOG_INFO("uriStr: %{private}s", uriStr.c_str());
|
||||
lock_guard<mutex> lock(nodeMutex_);
|
||||
HILOG_DEBUG("FindUri start");
|
||||
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");
|
||||
return;
|
||||
}
|
||||
if (connection->AsObject() == nullptr) {
|
||||
HILOG_ERROR("connection->AsObject() is nullptr");
|
||||
return;
|
||||
}
|
||||
connection->AsObject()->AddDeathRecipient(appDeathRecipient_);
|
||||
appProxyMap_[key] = value;
|
||||
appConnection_[key] = connection;
|
||||
|
@ -52,7 +52,11 @@ static void Deleter(struct NameListArg *arg)
|
||||
HILOG_ERROR("invalid argument");
|
||||
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]);
|
||||
(arg->namelist)[i] = nullptr;
|
||||
}
|
||||
@ -274,7 +278,7 @@ static int ScanDir(const string &path)
|
||||
HILOG_ERROR("Failed to request heap memory.");
|
||||
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);
|
||||
}
|
||||
} // OHOS::FileManagement
|
Loading…
Reference in New Issue
Block a user