diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/mkdir_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/mkdir_ani.cpp index a5cd88374fc3bf4e0af4e4eba32427439116a59f..737b53f4737024a6da3025fc2efeaf76baa4ce01 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/mkdir_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/mkdir_ani.cpp @@ -33,6 +33,7 @@ void MkdirkAni::MkdirSync0(ani_env *env, [[maybe_unused]] ani_class clazz, ani_s ErrorHandler::Throw(env, EINVAL); return; } + auto ret = MkdirCore::DoMkdir(pathStr); if (!ret.IsSuccess()) { HILOGE("Mkdir failed"); @@ -50,6 +51,7 @@ void MkdirkAni::MkdirSync1(ani_env *env, [[maybe_unused]] ani_class clazz, ani_s ErrorHandler::Throw(env, EINVAL); return; } + auto ret = MkdirCore::DoMkdir(pathStr, recursion); if (!ret.IsSuccess()) { HILOGE("DoMkdir failed"); diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/mkdir_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/mkdir_ani.h index 8ed780e9619e99f3390c2db0493d9063a9b37e33..195d0db0014c47ddacfe206b4838b47e8388b135 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/mkdir_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/mkdir_ani.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef INTERFACES_KITS_JS_SRC_MOD_FS_MKDIR_ANI_H -#define INTERFACES_KITS_JS_SRC_MOD_FS_MKDIR_ANI_H +#ifndef INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_ANI_MKDIR_ANI_H +#define INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_ANI_MKDIR_ANI_H #include @@ -34,4 +34,4 @@ public: } // namespace FileManagement } // namespace OHOS -#endif // INTERFACES_KITS_JS_SRC_MOD_FS_MKDIR_ANI_H +#endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_ANI_MKDIR_ANI_H diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/movedir_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/movedir_ani.cpp index e1239cfcac238550f114da14ecc43e078262efec..62281a917ee0ee18d0367d2b5d56544ebede5f2f 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/movedir_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/movedir_ani.cpp @@ -121,7 +121,7 @@ void MoveDirAni::MoveDirSync( auto [succMode, optMode] = TypeConverter::ToOptionalInt32(env, mode); if (!succMode) { - HILOGE("Failed to convert mode to int32"); + HILOGE("Invalid mode"); ErrorHandler::Throw(env, EINVAL); return; } @@ -140,6 +140,7 @@ void MoveDirAni::MoveDirSync( return; } } + } // namespace ANI } // namespace ModuleFileIO } // namespace FileManagement diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/read_lines_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/read_lines_ani.cpp index 49b26f784cd53a4650918a391e78cf725a63d9cd..10c3ce394cbca152b0576a82b45d521f9f23fc9f 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/read_lines_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/read_lines_ani.cpp @@ -53,7 +53,7 @@ ani_object ReadLinesAni::ReadLinesSync( { auto [succPath, filePath] = TypeConverter::ToUTF8String(env, path); if (!succPath) { - HILOGE("Invalid path"); + HILOGE("Invalid path from ETS first argument"); ErrorHandler::Throw(env, EINVAL); return nullptr; } @@ -64,6 +64,7 @@ ani_object ReadLinesAni::ReadLinesSync( ErrorHandler::Throw(env, EINVAL); return nullptr; } + FsResult ret = ReadLinesCore::DoReadLines(filePath, opt); if (!ret.IsSuccess()) { HILOGE("Readlines failed"); @@ -71,6 +72,7 @@ ani_object ReadLinesAni::ReadLinesSync( ErrorHandler::Throw(env, err); return nullptr; } + const FsReaderIterator *readerIterator = ret.GetData().value(); auto result = ReaderIteratorAni::Wrap(env, move(readerIterator)); if (result == nullptr) { @@ -79,6 +81,7 @@ ani_object ReadLinesAni::ReadLinesSync( } return result; } + } // namespace ANI } // namespace ModuleFileIO } // namespace FileManagement diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/read_lines_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/read_lines_ani.h index 387298f813beb8631a9e49a2a30a196267bd12b6..3f1bfeb7252e7c71937aa5ee63ff3631f4ec8926 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/read_lines_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/read_lines_ani.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef INTERFACES_KITS_JS_SRC_MOD_FS_READ_LINES_ANI_H -#define INTERFACES_KITS_JS_SRC_MOD_FS_READ_LINES_ANI_H +#ifndef INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_ANI_READ_LINES_ANI_H +#define INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_ANI_READ_LINES_ANI_H #include @@ -33,4 +33,4 @@ public: } // namespace FileManagement } // namespace OHOS -#endif // INTERFACES_KITS_JS_SRC_MOD_FS_READ_LINES_ANI_H \ No newline at end of file +#endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_ANI_READ_LINES_ANI_H \ No newline at end of file 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 91a929d134e2b5443fe840fc16441cedf4e45f5e..763d6e72ed69c93edc91c7831a914408ab7e77d2 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 @@ -29,7 +29,7 @@ void UnlinkAni::UnlinkSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_s { auto [succ, pathStr] = TypeConverter::ToUTF8String(env, path); if (!succ) { - HILOGE("Invalid path"); + HILOGE("Invalid path from ETS first argument"); ErrorHandler::Throw(env, EINVAL); return; } diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/unlink_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/unlink_ani.h index 817b258000b9f13b5dbbc8f498b00cc74e7dc1e0..64aee8bd1952c4da7d0ef61922f219da98ddb62f 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/unlink_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/unlink_ani.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef INTERFACES_KITS_JS_SRC_MOD_FS_UNLINK_ANI_H -#define INTERFACES_KITS_JS_SRC_MOD_FS_UNLINK_ANI_H +#ifndef INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_ANI_UNLINK_ANI_H +#define INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_ANI_UNLINK_ANI_H #include @@ -33,4 +33,4 @@ public: } // namespace FileManagement } // namespace OHOS -#endif // INTERFACES_KITS_JS_SRC_MOD_FS_UNLINK_ANI_H \ No newline at end of file +#endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_ANI_UNLINK_ANI_H \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/xattr_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/xattr_ani.cpp index 47e6d92a513b2e3ed172026caa532a295519dabe..2a69e0bd2eec613648097dd54ae5ff88e71b276c 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/xattr_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/xattr_ani.cpp @@ -37,14 +37,14 @@ void XattrAni::SetXattrSync( auto [keySucc, keyStr] = TypeConverter::ToUTF8String(env, key); if (!keySucc) { - HILOGE("Invalid key"); + HILOGE("Invalid xattr key"); ErrorHandler::Throw(env, EINVAL); return; } auto [valueSucc, valueStr] = TypeConverter::ToUTF8String(env, value); if (!valueSucc) { - HILOGE("Invalid value"); + HILOGE("Invalid xattr value"); ErrorHandler::Throw(env, EINVAL); return; } @@ -69,7 +69,7 @@ ani_string XattrAni::GetXattrSync(ani_env *env, [[maybe_unused]] ani_class clazz auto [keySucc, keyStr] = TypeConverter::ToUTF8String(env, key); if (!keySucc) { - HILOGE("Invalid key"); + HILOGE("Invalid xattr key"); ErrorHandler::Throw(env, EINVAL); return nullptr; } diff --git a/interfaces/kits/js/src/mod_fs/properties/fdatasync_core.cpp b/interfaces/kits/js/src/mod_fs/properties/fdatasync_core.cpp index 57b479f2bf329f2cd5a97e4852e32d906bc69bcc..38996fda03d167806fb900266596364df9b134f0 100644 --- a/interfaces/kits/js/src/mod_fs/properties/fdatasync_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/fdatasync_core.cpp @@ -24,7 +24,6 @@ #include "filemgmt_libhilog.h" namespace OHOS::FileManagement::ModuleFileIO { -using namespace std; FsResult FDataSyncCore::DoFDataSync(const int32_t &fd) { diff --git a/interfaces/kits/js/src/mod_fs/properties/fdatasync_core.h b/interfaces/kits/js/src/mod_fs/properties/fdatasync_core.h index 8efb6f90722e0f6c342d58c293a84995ac1efda5..7f568834b8d3c911dbdcbd7720d6808e7a97dc9a 100644 --- a/interfaces/kits/js/src/mod_fs/properties/fdatasync_core.h +++ b/interfaces/kits/js/src/mod_fs/properties/fdatasync_core.h @@ -24,6 +24,5 @@ class FDataSyncCore final { public: static FsResult DoFDataSync(const int32_t &fd); }; -const std::string PROCEDURE_FDATASYNC_NAME = "FileIOFdatasync"; } // namespace OHOS::FileManagement::ModuleFileIO #endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_FDATASYNC_CORE_H \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/mkdir_core.h b/interfaces/kits/js/src/mod_fs/properties/mkdir_core.h index cc6793693dca3c355419aae57de9ccaaf7749d9a..46bc81a7005e32adade346fba90378a25bc9306d 100644 --- a/interfaces/kits/js/src/mod_fs/properties/mkdir_core.h +++ b/interfaces/kits/js/src/mod_fs/properties/mkdir_core.h @@ -28,7 +28,7 @@ public: static FsResult DoMkdir(const std::string& path, std::optional recursion = std::nullopt); }; constexpr int DIR_DEFAULT_PERM = 0770; -const std::string PROCEDURE_READTEXT_NAME = "FileIOMkdir"; + } // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS diff --git a/interfaces/kits/js/src/mod_fs/properties/mkdtemp_core.h b/interfaces/kits/js/src/mod_fs/properties/mkdtemp_core.h index e638655ba71a3985d200fdb6e360e872d49a5fc0..df936597f265e739e766715b4792ab4c565a8688 100644 --- a/interfaces/kits/js/src/mod_fs/properties/mkdtemp_core.h +++ b/interfaces/kits/js/src/mod_fs/properties/mkdtemp_core.h @@ -27,7 +27,7 @@ class MkdtempCore final { public: static FsResult DoMkdtemp(const std::string &path); }; -const std::string PROCEDURE_MKDTEMP_NAME = "FileIOMkdtemp"; + } // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS diff --git a/interfaces/kits/js/src/mod_fs/properties/movedir_core.h b/interfaces/kits/js/src/mod_fs/properties/movedir_core.h index e4db3553d908beb9d1966a6852d91afd26bd2fe1..f10eaa5321bce542448c6d5bce604c63e6060f7a 100755 --- a/interfaces/kits/js/src/mod_fs/properties/movedir_core.h +++ b/interfaces/kits/js/src/mod_fs/properties/movedir_core.h @@ -58,7 +58,6 @@ public: const std::string &src, const std::string &dest, std::optional mode = std::nullopt); }; -const std::string PROCEDURE_MOVEDIR_NAME = "FileIOMoveDir"; } // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS diff --git a/interfaces/kits/js/src/mod_fs/properties/read_lines_core.cpp b/interfaces/kits/js/src/mod_fs/properties/read_lines_core.cpp index 819215c30e9be4c365a6315fc8e078ade722960e..def3485440fbae571904db42d6443703ed3d1c42 100644 --- a/interfaces/kits/js/src/mod_fs/properties/read_lines_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/read_lines_core.cpp @@ -98,11 +98,7 @@ FsResult ReadLinesCore::DoReadLines(const string &path, opti HILOGE("Failed to get size of the file"); return FsResult::Error(ret); } - auto readeriterator = InstantiateReaderIterator(iterator, offset); - if (!readeriterator.IsSuccess()) { - return FsResult::Error(ENOMEM); - } - return FsResult::Success(readeriterator.GetData().value()); + return InstantiateReaderIterator(iterator, offset); } } // namespace ModuleFileIO diff --git a/interfaces/kits/js/src/mod_fs/properties/read_lines_core.h b/interfaces/kits/js/src/mod_fs/properties/read_lines_core.h index a450cc43188f2765786fde02ed8a2c8d07166ae9..67cae2c52183c08fd066431aee5daee23db5b776 100644 --- a/interfaces/kits/js/src/mod_fs/properties/read_lines_core.h +++ b/interfaces/kits/js/src/mod_fs/properties/read_lines_core.h @@ -37,7 +37,6 @@ public: const std::string &path, std::optional option = std::nullopt); }; -const std::string PROCEDURE_READLINES_NAME = "FileIOReadLines"; } // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS 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 ecb92452e2eeb401b856238f52175487ae824523..42e87cd0bd69694dd144e00949de3b98dd5456c1 100644 --- a/interfaces/kits/js/src/mod_fs/properties/unlink_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/unlink_core.cpp @@ -24,17 +24,16 @@ namespace OHOS { namespace FileManagement { namespace ModuleFileIO { -using namespace std; FsResult UnlinkCore::DoUnlink(const std::string &src) { - std::unique_ptr unlink_req = { + std::unique_ptr unlinkReq = { new uv_fs_t, FsUtils::FsReqCleanup }; - if (!unlink_req) { + if (!unlinkReq) { HILOGE("Failed to request heap memory."); return FsResult::Error(ENOMEM); } - int ret = uv_fs_unlink(nullptr, unlink_req.get(), src.c_str(), nullptr); + int ret = uv_fs_unlink(nullptr, unlinkReq.get(), src.c_str(), nullptr); if (ret < 0) { HILOGD("Failed to unlink with path"); return FsResult::Error(ret); diff --git a/interfaces/kits/js/src/mod_fs/properties/unlink_core.h b/interfaces/kits/js/src/mod_fs/properties/unlink_core.h index b2ea553f4b62130bc691bda5daca16dbe7bc28d4..5989bbda29217d938c1f539bedc29197198be31c 100755 --- a/interfaces/kits/js/src/mod_fs/properties/unlink_core.h +++ b/interfaces/kits/js/src/mod_fs/properties/unlink_core.h @@ -27,7 +27,7 @@ class UnlinkCore final { public: static FsResult DoUnlink(const std::string &src); }; -const std::string PROCEDURE_READTEXT_NAME = "FileIOUnlink"; + } // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS