diff --git a/interfaces/innerkits/native/file_uri/include/file_uri.h b/interfaces/innerkits/native/file_uri/include/file_uri.h index 8f175da91d50a5abf95e66ebafb0f6f71a4f1e8e..1f8f50410c7bbeebf2718b2df408b00983d10b69 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 2973a554aebef8f890ea558f66f686a96ae4185b..ddb7aac286635c2eaf12283470a7cdb4a2cbc173 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();