diff --git a/interfaces/innerkits/native/file_share/src/file_share.cpp b/interfaces/innerkits/native/file_share/src/file_share.cpp index be352eafdb10ce85c32638be6247ad42cdabe2d6..674a3516b8532eeac82323953717fd2587643f31 100644 --- a/interfaces/innerkits/native/file_share/src/file_share.cpp +++ b/interfaces/innerkits/native/file_share/src/file_share.cpp @@ -116,6 +116,7 @@ static int32_t GetLowerPath(string &lowerPathHead, const string &lowerPathTail, return -EINVAL; } if (lowerPathHead.find(PID_FLAG) != string::npos) { + pid.erase(pid.size() - 1); lowerPathHead = lowerPathHead.replace(lowerPathHead.find(PID_FLAG), PID_FLAG.length(), pid); } @@ -266,14 +267,6 @@ static bool RemoveDir(const string& path) return true; } -static bool DeleteDir(const string &path) -{ - if (IsExistDir(path)) { - return RemoveDir(path); - } - return false; -} - static int32_t PreparePreShareDir(FileShareInfo &info) { for (size_t i = 0; i < info.sharePath_.size(); i++) { @@ -347,11 +340,15 @@ static void UmountDelUris(vector sharePathList, string currentUid, strin if (umount2(delRPath.c_str(), MNT_DETACH) != 0) { LOGE("UmountdelRPath, umount failed with %{public}d", errno); } + + remove(delRPath.c_str()); } if (access(delRWPath.c_str(), F_OK) == 0) { if (umount2(delRWPath.c_str(), MNT_DETACH) != 0) { LOGE("UmountdelRWPath, umount failed with %{public}d", errno); } + + remove(delRWPath.c_str()); } } } @@ -366,12 +363,6 @@ int32_t FileShare::DeleteShareFile(uint32_t tokenId, vector sharePathLis } UmountDelUris(sharePathList, currentUid, bundleName); - string sharePath = DATA_APP_EL2_PATH + currentUid + SHARE_PATH + bundleName; - if ((access(sharePath.c_str(), F_OK) == 0) && !DeleteDir(sharePath)) { - LOGE("Delete dir failed with %{public}d", errno); - return -errno; - } - LOGI("Delete Share File Successfully!"); return 0; }