From 9ad23f7787db6f3f5a04a6d92b326add033bb977 Mon Sep 17 00:00:00 2001 From: tao-jinpei Date: Thu, 21 Aug 2025 14:12:54 +0800 Subject: [PATCH] =?UTF-8?q?RmDirectory=20errCode=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tao-jinpei Change-Id: I9fb49d2e1d35d65b9de358ef7a4c0b4baa63a371 --- .../kits/js/src/mod_fs/properties/movedir.cpp | 20 +++++++++---------- .../js/src/mod_fs/properties/movedir_core.cpp | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/properties/movedir.cpp b/interfaces/kits/js/src/mod_fs/properties/movedir.cpp index 31eee911c..ad20b7f37 100644 --- a/interfaces/kits/js/src/mod_fs/properties/movedir.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/movedir.cpp @@ -52,17 +52,17 @@ static tuple JudgeExistAndEmpty(const string &path) static int RmDirectory(const string &path) { filesystem::path pathName(path); - std::error_code errCode; - if (filesystem::exists(pathName, errCode)) { - std::error_code errCode; - (void)filesystem::remove_all(pathName, errCode); - if (errCode.value() != 0) { - HILOGE("Failed to remove directory, error code: %{public}d", errCode.value()); - return errCode.value(); + std::error_code existsErrCode; + if (filesystem::exists(pathName, existsErrCode)) { + std::error_code removeErrCode; + (void)filesystem::remove_all(pathName, removeErrCode); + if (removeErrCode.value() != 0) { + HILOGE("Failed to remove directory, error code: %{public}d", removeErrCode.value()); + return removeErrCode.value(); } - } else if (errCode.value() != ERRNO_NOERR) { - HILOGE("fs exists fail, errcode is %{public}d", errCode.value()); - return errCode.value(); + } else if (existsErrCode.value() != ERRNO_NOERR) { + HILOGE("fs exists fail, errcode is %{public}d", existsErrCode.value()); + return existsErrCode.value(); } return ERRNO_NOERR; } diff --git a/interfaces/kits/js/src/mod_fs/properties/movedir_core.cpp b/interfaces/kits/js/src/mod_fs/properties/movedir_core.cpp index 2b7e49e8d..df5797e65 100644 --- a/interfaces/kits/js/src/mod_fs/properties/movedir_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/movedir_core.cpp @@ -50,17 +50,17 @@ static tuple JudgeExistAndEmpty(const string &path) static int RmDirectory(const string &path) { filesystem::path pathName(path); - std::error_code errCode; - if (filesystem::exists(pathName, errCode)) { - std::error_code errCode; - (void)filesystem::remove_all(pathName, errCode); - if (errCode.value() != 0) { - HILOGE("Failed to remove directory, error code: %{public}d", errCode.value()); - return errCode.value(); + std::error_code existsErrCode; + if (filesystem::exists(pathName, existsErrCode)) { + std::error_code removeErrCode; + (void)filesystem::remove_all(pathName, removeErrCode); + if (removeErrCode.value() != 0) { + HILOGE("Failed to remove directory, error code: %{public}d", removeErrCode.value()); + return removeErrCode.value(); } - } else if (errCode.value() != ERRNO_NOERR) { - HILOGE("Fs exists fail, errcode is %{public}d", errCode.value()); - return errCode.value(); + } else if (existsErrCode.value() != ERRNO_NOERR) { + HILOGE("Fs exists fail, errcode is %{public}d", existsErrCode.value()); + return existsErrCode.value(); } return ERRNO_NOERR; } -- Gitee