跨设备文件分享路径转换

Signed-off-by: cuiruibin <cuiruibin3@huawei.com>
This commit is contained in:
cuiruibin 2024-03-28 15:25:35 +08:00
parent daef50e12c
commit 166a3aedee
2 changed files with 4 additions and 2 deletions

View File

@ -89,7 +89,8 @@ string FileUri::GetRealPath()
return realPath;
}
if ((bundleName != "") && (bundleName != CommonFunc::GetSelfBundleName())) {
if (((bundleName != "") && (bundleName != CommonFunc::GetSelfBundleName())) ||
uri_.ToString().find(NETWORK_PARA) != string::npos) {
realPath = PATH_SHARE + MODE_RW + bundleName + sandboxPath;
if (access(realPath.c_str(), F_OK) != 0) {
realPath = PATH_SHARE + MODE_R + bundleName + sandboxPath;

View File

@ -151,7 +151,8 @@ HWTEST_F(NDKFileUriTest, get_path_from_uri_test_004, TestSize.Level1)
fileUriStr += "data/storage/el2/base/haps/entry/files/GetPathFromUri004.txt";
fileUriStr += "?networkid=64799ecdf70788e396f454ff4a6e6ae4b09e20227c39c21f6e67a2aacbcef7b9";
const char *fileUri = fileUriStr.c_str();
std::string filePathStr = "/data/storage/el2/distributedfiles/.remote_share/";
std::string filePathStr =
"/data/storage/el2/share/r/" + BUNDLE_A + "/data/storage/el2/distributedfiles/.remote_share/";
filePathStr += "data/storage/el2/base/haps/entry/files/GetPathFromUri004.txt";
const char *filePath = filePathStr.c_str();
char *result = nullptr;