diff --git a/interfaces/kits/js/src/mod_fs/properties/copydir.cpp b/interfaces/kits/js/src/mod_fs/properties/copydir.cpp index 493a6f1cf4735ac6c245cddd60bc0a390f00cefa..9fea4356c26b88126d73ab69dec31d8a09267740 100644 --- a/interfaces/kits/js/src/mod_fs/properties/copydir.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/copydir.cpp @@ -48,13 +48,14 @@ static tuple, unique_ptr, int> ParseAndCheckJsO const NFuncArg &funcArg) { auto [resGetFirstArg, src, ignore] = NVal(env, funcArg[NARG_POS::FIRST]).ToUTF8StringPath(); - if (!resGetFirstArg || !filesystem::is_directory(filesystem::status(src.get()))) { - HILOGE("Invalid src"); + std::error_code errCode; + if (!resGetFirstArg || !filesystem::is_directory(filesystem::status(src.get(), errCode))) { + HILOGE("Invalid src, errCode = %{public}d", errCode.value()); return { false, nullptr, nullptr, 0 }; } auto [resGetSecondArg, dest, unused] = NVal(env, funcArg[NARG_POS::SECOND]).ToUTF8StringPath(); - if (!resGetSecondArg || !filesystem::is_directory(filesystem::status(dest.get()))) { - HILOGE("Invalid dest"); + if (!resGetSecondArg || !filesystem::is_directory(filesystem::status(dest.get(), errCode))) { + HILOGE("Invalid dest, errCode = %{public}d", errCode.value()); return { false, nullptr, nullptr, 0 }; } if (!AllowToCopy(src.get(), dest.get())) { diff --git a/interfaces/kits/js/src/mod_fs/properties/move.cpp b/interfaces/kits/js/src/mod_fs/properties/move.cpp index 59e7fb97fb501d95d604944ce86cc217279b0d5e..f75481d88910412010851d4e843ac3cc972bb6a2 100644 --- a/interfaces/kits/js/src/mod_fs/properties/move.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/move.cpp @@ -37,7 +37,8 @@ using namespace OHOS::FileManagement::LibN; #ifdef __MUSL__ static bool CheckDir(const string &path) { - if (!filesystem::is_directory(filesystem::status(path))) { + std::error_code errCode; + if (!filesystem::is_directory(filesystem::status(path, errCode))) { return false; } return true; diff --git a/interfaces/kits/js/src/mod_fs/properties/movedir.cpp b/interfaces/kits/js/src/mod_fs/properties/movedir.cpp index 4a6a8781cac5658fa06bd38994eb0052c9b8517d..69231819f932daa035aeb6b47c03997c56f75666 100644 --- a/interfaces/kits/js/src/mod_fs/properties/movedir.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/movedir.cpp @@ -41,7 +41,7 @@ static tuple JudgeExistAndEmpty(const string &path) std::error_code errCode; filesystem::path pathName(path); if (filesystem::exists(pathName, errCode)) { - if (filesystem::is_empty(pathName)) { + if (filesystem::is_empty(pathName, errCode)) { return { true, true }; } return { true, false }; @@ -81,13 +81,14 @@ static int RemovePath(const string& pathStr) static tuple, unique_ptr, int> ParseJsOperand(napi_env env, const NFuncArg& funcArg) { auto [resGetFirstArg, src, ignore] = NVal(env, funcArg[NARG_POS::FIRST]).ToUTF8StringPath(); - if (!resGetFirstArg || !filesystem::is_directory(filesystem::status(src.get()))) { - HILOGE("Invalid src"); + std::error_code errCode; + if (!resGetFirstArg || !filesystem::is_directory(filesystem::status(src.get(), errCode))) { + HILOGE("Invalid src, errCode = %{public}d", errCode.value()); return { false, nullptr, nullptr, 0 }; } auto [resGetSecondArg, dest, unused] = NVal(env, funcArg[NARG_POS::SECOND]).ToUTF8StringPath(); - if (!resGetSecondArg || !filesystem::is_directory(filesystem::status(dest.get()))) { - HILOGE("Invalid dest"); + if (!resGetSecondArg || !filesystem::is_directory(filesystem::status(dest.get(), errCode))) { + HILOGE("Invalid dest,errCode = %{public}d", errCode.value()); return { false, nullptr, nullptr, 0 }; } int mode = 0; @@ -200,7 +201,8 @@ static int RecurMoveDir(const string &srcPath, const string &destPath, const int deque &errfiles) { filesystem::path dpath(destPath); - if (!filesystem::is_directory(dpath)) { + std::error_code errCode; + if (!filesystem::is_directory(dpath, errCode)) { errfiles.emplace_front(srcPath, destPath); return ERRNO_NOERR; }