From eb596e005935a23e59eccecbc266aa98de74334c Mon Sep 17 00:00:00 2001 From: wangpggg Date: Thu, 7 Sep 2023 18:01:18 +0800 Subject: [PATCH] modify the interface GetUriFromPath Signed-off-by: wangpeng --- interfaces/common/src/common_func.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interfaces/common/src/common_func.cpp b/interfaces/common/src/common_func.cpp index 7288d16cd..adde788f7 100644 --- a/interfaces/common/src/common_func.cpp +++ b/interfaces/common/src/common_func.cpp @@ -33,6 +33,8 @@ using namespace OHOS::AppExecFwk; namespace { const std::string FILE_SCHEME_PREFIX = "file://"; const char BACKFLASH = '/'; + const std::string FILE_MANAGER_URI_HEAD = "/storage/"; + const std::string FILE_MANAGER_AUTHORITY = "docs"; } static sptr GetBundleMgrProxy() { @@ -89,7 +91,7 @@ string CommonFunc::GetUriFromPath(const string &path) string realPath = path; NormalizePath(realPath); - string packageName = GetSelfBundleName(); + string packageName = (path.find(FILE_MANAGER_URI_HEAD) == 0) ? FILE_MANAGER_AUTHORITY : GetSelfBundleName(); realPath = FILE_SCHEME_PREFIX + packageName + realPath; return SandboxHelper::Encode(realPath); } -- Gitee