From da91754646b315aadc7592c3ae953fb0dc55e21b Mon Sep 17 00:00:00 2001 From: tianp Date: Tue, 5 Aug 2025 14:54:01 +0800 Subject: [PATCH] =?UTF-8?q?unlink=E6=8E=A5=E5=8F=A3=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tianp Change-Id: I2389f50e8fa0de24382742438b1061a72faf6c8f --- interfaces/kits/js/src/mod_fs/properties/ani/unlink_ani.cpp | 1 + interfaces/kits/js/src/mod_fs/properties/unlink_core.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/unlink_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/unlink_ani.cpp index 763d6e72e..704ae58a2 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/unlink_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/unlink_ani.cpp @@ -33,6 +33,7 @@ void UnlinkAni::UnlinkSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_s ErrorHandler::Throw(env, EINVAL); return; } + auto ret = UnlinkCore::DoUnlink(pathStr); if (!ret.IsSuccess()) { HILOGE("Unlink failed"); diff --git a/interfaces/kits/js/src/mod_fs/properties/unlink_core.cpp b/interfaces/kits/js/src/mod_fs/properties/unlink_core.cpp index 339b56db0..cff5a2af7 100644 --- a/interfaces/kits/js/src/mod_fs/properties/unlink_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/unlink_core.cpp @@ -26,14 +26,14 @@ namespace FileManagement { namespace ModuleFileIO { using namespace std; -FsResult UnlinkCore::DoUnlink(const std::string &src) +FsResult UnlinkCore::DoUnlink(const string &src) { - std::unique_ptr unlinkReq = { - new uv_fs_t, FsUtils::FsReqCleanup }; + unique_ptr unlinkReq = { new uv_fs_t, FsUtils::FsReqCleanup }; if (!unlinkReq) { HILOGE("Failed to request heap memory."); return FsResult::Error(ENOMEM); } + int ret = uv_fs_unlink(nullptr, unlinkReq.get(), src.c_str(), nullptr); if (ret < 0) { HILOGD("Failed to unlink with path"); -- Gitee