From bbd46914a97346d2a68e6be3277aff5e6ca02b04 Mon Sep 17 00:00:00 2001 From: cuiruibin Date: Wed, 17 Jul 2024 09:36:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BD=AC=E6=8D=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20Signed-off-by:=20cuiruibin=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../innerkits/native/file_uri/include/file_uri.h | 1 + .../innerkits/native/file_uri/src/file_uri.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/interfaces/innerkits/native/file_uri/include/file_uri.h b/interfaces/innerkits/native/file_uri/include/file_uri.h index 8f175da91..1f8f50410 100644 --- a/interfaces/innerkits/native/file_uri/include/file_uri.h +++ b/interfaces/innerkits/native/file_uri/include/file_uri.h @@ -26,6 +26,7 @@ class FileUri { public: std::string GetName(); std::string GetPath(); + std::string GetRealPathBySA(const std::string &targetBundleName = ""); std::string GetRealPath(); std::string ToString(); std::string GetFullDirectoryUri(); diff --git a/interfaces/innerkits/native/file_uri/src/file_uri.cpp b/interfaces/innerkits/native/file_uri/src/file_uri.cpp index 2973a554a..ddb7aac28 100644 --- a/interfaces/innerkits/native/file_uri/src/file_uri.cpp +++ b/interfaces/innerkits/native/file_uri/src/file_uri.cpp @@ -99,6 +99,20 @@ string FileUri::GetRealPath() return realPath; } +string FileUri::GetRealPathBySA(const std::string &targetBundleName) +{ + string sandboxPath = SandboxHelper::Decode(uri_.GetPath()); + string realPath = sandboxPath; + string bundleName = uri_.GetAuthority(); + if (bundleName == FILE_MANAGER_AUTHORITY && + uri_.ToString().find(NETWORK_PARA) == string::npos && + (access(realPath.c_str(), F_OK) == 0 || CheckFileManagerFullMountEnable())) { + return realPath; + } + realPath = PATH_SHARE + MODE_R + bundleName + sandboxPath; + return realPath; +} + string FileUri::ToString() { return uri_.ToString(); -- Gitee