From 7d3964571501a7e12f0da12a43480d639447cc00 Mon Sep 17 00:00:00 2001 From: zhangxiaoliang25 Date: Sun, 9 Mar 2025 00:29:23 +0800 Subject: [PATCH] =?UTF-8?q?gn=20=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangxiaoliang25 Change-Id: I675601aca1c1dd7ab69ab9465c56eeb6d97d4ada --- bundle.json | 16 +- interfaces/kits/js/BUILD.gn | 292 ++++++++++++++++++ .../src/common/ani_helper/type_converter.cpp | 28 ++ .../js/src/common/ani_helper/type_converter.h | 2 + .../kits/js/src/common/fs_file_filter.h | 117 +++++++ .../js/src/mod_fs/ani/bind_function_class.cpp | 78 +++++ .../src/mod_fs/properties/ani/access_ani.cpp | 10 +- .../src/mod_fs/properties/ani/close_ani.cpp | 4 +- .../js/src/mod_fs/properties/ani/close_ani.h | 4 +- .../mod_fs/properties/ani/listfile_ani.cpp | 4 +- .../src/mod_fs/properties/ani/listfile_ani.h | 4 +- .../src/mod_fs/properties/ani/mkdir_ani.cpp | 4 +- .../mod_fs/properties/ani/read_text_ani.cpp | 4 +- .../src/mod_fs/properties/ani/read_text_ani.h | 4 +- .../src/mod_fs/properties/ani/unlink_ani.cpp | 2 +- .../js/src/mod_fs/properties/mkdir_core.cpp | 12 +- .../js/src/mod_fs/properties/mkdir_core.h | 4 +- .../kits/js/src/mod_hash/ani/hash_ani.cpp | 2 +- .../kits/js/src/mod_hash/ani/hash_ani.h | 2 +- .../ani/securitylabel_ani.cpp | 2 +- .../mod_securitylabel/ani/securitylabel_ani.h | 2 +- 21 files changed, 562 insertions(+), 35 deletions(-) create mode 100644 interfaces/kits/js/src/common/fs_file_filter.h create mode 100644 interfaces/kits/js/src/mod_fs/ani/bind_function_class.cpp diff --git a/bundle.json b/bundle.json index 60c317e0e..34a4f196e 100644 --- a/bundle.json +++ b/bundle.json @@ -41,9 +41,11 @@ "ipc", "init", "napi", + "runtime_core", "samgr", "app_file_service", - "os_account" + "os_account", + "libuv" ], "third_party": [ "e2fsprogs", @@ -56,7 +58,8 @@ "fwk_group": [ "//foundation/filemanagement/file_api/interfaces/kits/js:build_kits_js", "//foundation/filemanagement/file_api/interfaces/kits/ts/streamrw:streamrw_packages", - "//foundation/filemanagement/file_api/interfaces/kits/ts/streamhash:streamhash_packages" + "//foundation/filemanagement/file_api/interfaces/kits/ts/streamhash:streamhash_packages", + "//foundation/filemanagement/file_api/interfaces/kits/js:ani_file_api" ], "service_group": [] }, @@ -97,6 +100,15 @@ "header_base": "//foundation/filemanagement/file_api/interfaces/kits/rust/include" } }, + { + "name": "//foundation/filemanagement/file_api/utils/filemgmt_libfs:filemgmt_libfs", + "header": { + "header_files": [ + "filemgmt_libfs.h" + ], + "header_base": "//foundation/filemanagement/file_api/utils/filemgmt_libfs/include" + } + }, { "name": "//foundation/filemanagement/file_api/utils/filemgmt_libn:filemgmt_libn", "header": { diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 3c9b376ee..1a7c2014b 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/ets_frontend/ets2abc_config.gni") import("//build/ohos.gni") import("//foundation/filemanagement/file_api/file_api.gni") @@ -618,3 +619,294 @@ group("build_kits_js") { ":statvfs", ] } + +group("ani_file_api") { + deps = [ + ":ani_fs_class", + ":ani_hash_class", + ":ani_securitylabel_class", + ] +} + +config("ani_config") { + include_dirs = [ + "./include", + "${file_api_path}/interfaces/kits/rust/include", + "${utils_path}/common/include", + "${utils_path}/filemgmt_libfs/include", + "${utils_path}/filemgmt_libhilog", + "src/common", + "src/common/ani_helper", + "src/common/file_helper", + "src/mod_fs", + ] + + cflags = [ + "-fvisibility=hidden", + "-fdata-sections", + "-ffunction-sections", + "-Oz", + ] + cflags_cc = [ + "-std=c++17", + "-fvisibility-inlines-hidden", + "-Oz", + "-Wno-unused-function", + ] +} + +ohos_shared_library("ani_fs_class") { + public_configs = [ ":ani_config" ] + include_dirs = [ + "include/ipc", + "src/mod_fs/ani", + "src/mod_fs/class_file", + "src/mod_fs/class_stat", + "src/mod_fs/properties", + "src/mod_fs/properties/ani", + "src/mod_fs/properties/copy_listener", + ] + sources = [ + "src/common/ani_helper/bind_function.cpp", + "src/common/ani_helper/type_converter.cpp", + "src/common/file_helper/fd_guard.cpp", + "src/mod_fs/ani/bind_function_class.cpp", + "src/mod_fs/class_file/ani/file_ani.cpp", + "src/mod_fs/class_file/fs_file.cpp", + "src/mod_fs/class_stat/fs_stat.cpp", + "src/mod_fs/fs_utils.cpp", + "src/mod_fs/properties/access_core.cpp", + "src/mod_fs/properties/ani/access_ani.cpp", + "src/mod_fs/properties/ani/close_ani.cpp", + "src/mod_fs/properties/ani/copy_file_ani.cpp", + "src/mod_fs/properties/ani/listfile_ani.cpp", + "src/mod_fs/properties/ani/mkdir_ani.cpp", + "src/mod_fs/properties/ani/move_ani.cpp", + "src/mod_fs/properties/ani/open_ani.cpp", + "src/mod_fs/properties/ani/read_ani.cpp", + "src/mod_fs/properties/ani/read_text_ani.cpp", + "src/mod_fs/properties/ani/rmdir_ani.cpp", + "src/mod_fs/properties/ani/stat_ani.cpp", + "src/mod_fs/properties/ani/truncate_ani.cpp", + "src/mod_fs/properties/ani/unlink_ani.cpp", + "src/mod_fs/properties/ani/write_ani.cpp", + "src/mod_fs/properties/close_core.cpp", + "src/mod_fs/properties/copy_file_core.cpp", + "src/mod_fs/properties/listfile_core.cpp", + "src/mod_fs/properties/mkdir_core.cpp", + "src/mod_fs/properties/move_core.cpp", + "src/mod_fs/properties/open_core.cpp", + "src/mod_fs/properties/read_core.cpp", + "src/mod_fs/properties/read_text_core.cpp", + "src/mod_fs/properties/rmdir_core.cpp", + "src/mod_fs/properties/stat_core.cpp", + "src/mod_fs/properties/truncate_core.cpp", + "src/mod_fs/properties/unlink_core.cpp", + "src/mod_fs/properties/write_core.cpp", + ] + deps = [ + ":ani_fs_abc_etc", + "${file_api_path}/interfaces/kits/native:remote_uri_native", + "${file_api_path}/interfaces/kits/rust:rust_file", + "${utils_path}/filemgmt_libfs:filemgmt_libfs", + "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", + ] + use_exceptions = true + external_deps = [ + "ability_runtime:ability_manager", + "app_file_service:fileuri_native", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "data_share:datashare_common", + "data_share:datashare_consumer", + "dfs_service:distributed_file_daemon_kit_inner", + "hilog:libhilog", + "ipc:ipc_core", + "libuv:uv", + "runtime_core:ani", + "runtime_core:libarkruntime", + "samgr:samgr_proxy", + ] + + cflags = [ + "-fvisibility=hidden", + "-fdata-sections", + "-ffunction-sections", + "-Oz", + ] + cflags_cc = [ + "-std=c++17", + "-fvisibility-inlines-hidden", + "-Oz", + "-Wno-unused-function", + ] + branch_protector_ret = "pac_ret" + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + subsystem_name = "filemanagement" + part_name = "file_api" +} + +generate_static_abc("ani_fs_abc") { + arktsconfig = "src/mod_fs/ani/arktsconfig.json" + dst_file = "$target_out_dir/ani_fs.abc" + out_puts = [ "$target_out_dir/ani_fs.abc" ] + is_boot_abc = "True" + device_dst_file = "/system/framework/ani_fs.abc" + cache_path = "$target_out_dir/cache" +} + +ohos_prebuilt_etc("ani_fs_abc_etc") { + source = "$target_out_dir/ani_fs.abc" + module_install_dir = "fs" + subsystem_name = "filemanagement" + part_name = "file_api" + deps = [ ":ani_fs_abc" ] +} + +ohos_shared_library("ani_hash_class") { + public_configs = [ ":ani_config" ] + include_dirs = [ + "src/mod_hash", + "src/mod_hash/ani", + ] + sources = [ + "src/common/ani_helper/bind_function.cpp", + "src/common/ani_helper/type_converter.cpp", + "src/common/file_helper/fd_guard.cpp", + "src/common/file_helper/hash_file.cpp", + "src/mod_fs/fs_utils.cpp", + "src/mod_hash/ani/bind_function_class.cpp", + "src/mod_hash/ani/hash_ani.cpp", + "src/mod_hash/hash_core.cpp", + ] + + deps = [ + ":ani_hash_abc_etc", + "${file_api_path}/interfaces/kits/rust:rust_file", + "${utils_path}/filemgmt_libfs:filemgmt_libfs", + "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", + "//third_party/openssl:libcrypto_shared", + ] + external_deps = [ + "hilog:libhilog", + "libuv:uv", + "runtime_core:ani", + "runtime_core:libarkruntime", + ] + use_exceptions = true + cflags = [ + "-fvisibility=hidden", + "-fdata-sections", + "-ffunction-sections", + "-Oz", + ] + cflags_cc = [ + "-fvisibility-inlines-hidden", + "-Oz", + ] + branch_protector_ret = "pac_ret" + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + subsystem_name = "filemanagement" + part_name = "file_api" +} + +generate_static_abc("ani_hash_abc") { + arktsconfig = "src/mod_hash/ani/arktsconfig.json" + dst_file = "$target_out_dir/ani_hash.abc" + out_puts = [ "$target_out_dir/ani_hash.abc" ] + is_boot_abc = "True" + device_dst_file = "/system/framework/ani_hash.abc" + cache_path = "$target_out_dir/cache" +} + +ohos_prebuilt_etc("ani_hash_abc_etc") { + source = "$target_out_dir/ani_hash.abc" + module_install_dir = "hash" + subsystem_name = "filemanagement" + part_name = "file_api" + deps = [ ":ani_hash_abc" ] +} + +ohos_shared_library("ani_securitylabel_class") { + public_configs = [ ":ani_config" ] + include_dirs = [ + "src/mod_securitylabel/ani", + "src/mod_securitylabel", + ] + sources = [ + "src/common/ani_helper/bind_function.cpp", + "src/common/ani_helper/type_converter.cpp", + "src/common/file_helper/fd_guard.cpp", + "src/mod_fs/fs_utils.cpp", + "src/mod_securitylabel/ani/bind_function_class.cpp", + "src/mod_securitylabel/ani/securitylabel_ani.cpp", + "src/mod_securitylabel/securitylabel_core.cpp", + ] + + deps = [ + ":ani_securitylabel_abc_etc", + "${file_api_path}/interfaces/kits/rust:rust_file", + "${utils_path}/filemgmt_libfs:filemgmt_libfs", + "${utils_path}/filemgmt_libhilog:filemgmt_libhilog", + ] + external_deps = [ + "hilog:libhilog", + "libuv:uv", + "runtime_core:ani", + "runtime_core:libarkruntime", + ] + use_exceptions = true + cflags = [ + "-fvisibility=hidden", + "-fdata-sections", + "-ffunction-sections", + "-Oz", + ] + cflags_cc = [ + "-fvisibility-inlines-hidden", + "-Oz", + ] + branch_protector_ret = "pac_ret" + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + subsystem_name = "filemanagement" + part_name = "file_api" +} + +generate_static_abc("ani_securitylabel_abc") { + arktsconfig = "src/mod_securitylabel/ani/arktsconfig.json" + dst_file = "$target_out_dir/ani_securitylabel.abc" + out_puts = [ "$target_out_dir/ani_securitylabel.abc" ] + is_boot_abc = "True" + device_dst_file = "/system/framework/ani_securitylabel.abc" + cache_path = "$target_out_dir/cache" +} + +ohos_prebuilt_etc("ani_securitylabel_abc_etc") { + source = "$target_out_dir/ani_securitylabel.abc" + module_install_dir = "securitylabel" + subsystem_name = "filemanagement" + part_name = "file_api" + deps = [ ":ani_securitylabel_abc" ] +} diff --git a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp index d5499e2e5..ab5c29d70 100644 --- a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp +++ b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp @@ -147,4 +147,32 @@ std::tuple TypeConverter::ToArrayBuffer(ani_env *env, ani_arr return { true, ArrayBuffer { std::move(buf), length } }; } +std::tuple TypeConverter::ToAniStringList( + ani_env *env, const std::string strList[], const uint32_t length) +{ + ani_array_ref result = nullptr; + ani_class itemCls = nullptr; + if (env->FindClass("Lstd/core/String;", &itemCls) != ANI_OK) { + HILOGE("FindClass String class Fail"); + return { false, result }; + } + if (env->Array_New_Ref(itemCls, length, nullptr, &result) != ANI_OK) { + HILOGE("Array_New_Ref Fail"); + return { false, result }; + } + for (int i = 0; i < length; i++) { + auto [ret, item] = TypeConverter::ToAniString(env, strList[i]); + if (!ret) { + HILOGE("ToAniString Fail"); + return { false, nullptr }; + } + + if (env->Array_Set_Ref(result, i, item) != ANI_OK) { + HILOGE("Array_Set_Ref Fail"); + return { false, nullptr }; + } + } + return { true, result }; +} + } // namespace OHOS::FileManagement::ModuleFileIO::ANI \ No newline at end of file diff --git a/interfaces/kits/js/src/common/ani_helper/type_converter.h b/interfaces/kits/js/src/common/ani_helper/type_converter.h index c4bbfc2b9..a74a0065b 100644 --- a/interfaces/kits/js/src/common/ani_helper/type_converter.h +++ b/interfaces/kits/js/src/common/ani_helper/type_converter.h @@ -36,6 +36,8 @@ public: static std::tuple ToAniString(ani_env *env, const char *str); static std::tuple ToFileInfo(ani_env *env, const ani_object &pathOrFd); static std::tuple ToArrayBuffer(ani_env *env, ani_arraybuffer &buffer); + static std::tuple ToAniStringList( + ani_env *env, const std::string strList[], const uint32_t length); }; } // namespace OHOS::FileManagement::ModuleFileIO::ANI diff --git a/interfaces/kits/js/src/common/fs_file_filter.h b/interfaces/kits/js/src/common/fs_file_filter.h new file mode 100644 index 000000000..f16c17821 --- /dev/null +++ b/interfaces/kits/js/src/common/fs_file_filter.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef FS_FILE_FILTER_H +#define FS_FILE_FILTER_H + +#include +#include +#include + +namespace OHOS { +namespace FileManagement { +namespace ModuleFileIO { + +class FsFileFilter { +public: + FsFileFilter() = default; + ~FsFileFilter() = default; + + FsFileFilter(const FsFileFilter &filter) = default; + FsFileFilter &operator=(const FsFileFilter &filter) = default; + + void SetSuffix(const std::optional> &suffix) + { + suffix_ = std::move(suffix); + } + + const std::optional> &GetSuffix() const + { + return suffix_; + } + + void SetDisplayName(const std::optional> &displayName) + { + displayName_ = std::move(displayName); + } + + const std::optional> &GetDisplayName() const + { + return displayName_; + } + + void SetMimeType(const std::optional> &mimeType) + { + mimeType_ = std::move(mimeType); + } + + const std::optional> &GetMimeType() const + { + return mimeType_; + } + + void SetFileSizeOver(const std::optional &fileSizeOver) + { + fileSizeOver_ = std::move(fileSizeOver); + } + + const std::optional &GetFileSizeOver() const + { + return fileSizeOver_; + } + + void SetLastModifiedAfter(const std::optional &lastModifiedAfter) + { + lastModifiedAfter_ = std::move(lastModifiedAfter); + } + + const std::optional &GetLastModifiedAfter() const + { + return lastModifiedAfter_; + } + + void SetExcludeMedia(const bool &excludeMedia) + { + excludeMedia_ = excludeMedia; + } + + bool GetExcludeMedia() const + { + return excludeMedia_; + } + + void SetHasFilter(const bool &hasFilter) + { + hasFilter_ = hasFilter; + } + + bool GetHasFilter() const + { + return hasFilter_; + } + +private: + std::optional> suffix_ = std::nullopt; + std::optional> displayName_ = std::nullopt; + std::optional> mimeType_ = std::nullopt; + std::optional fileSizeOver_ = std::nullopt; + std::optional lastModifiedAfter_ = std::nullopt; + bool excludeMedia_ = false; + bool hasFilter_ = false; +}; + +} // namespace ModuleFileIO +} // namespace FileManagement +} // namespace OHOS +#endif // FS_FILE_FILTER_H \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/ani/bind_function_class.cpp b/interfaces/kits/js/src/mod_fs/ani/bind_function_class.cpp new file mode 100644 index 000000000..9498f8479 --- /dev/null +++ b/interfaces/kits/js/src/mod_fs/ani/bind_function_class.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include "access_ani.h" +#include "bind_function.h" +#include "copy_file_ani.h" +#include "mkdir_ani.h" +#include "move_ani.h" +#include "stat_ani.h" +#include "unlink_ani.h" +#include "rmdir_ani.h" + +using namespace OHOS::FileManagement::ModuleFileIO::ANI; + +static ani_status BindStatMethods(ani_vm *vm) +{ + static const char *className = "Lfile_fs_class/StatInner;"; + + std::vector methods = { + ani_native_function { "isBlockDevice", ":Z", reinterpret_cast(StatAni::IsBlockDevice) }, + ani_native_function { "isCharacterDevice", ":Z", reinterpret_cast(StatAni::IsCharacterDevice) }, + ani_native_function { "isDirectory", ":Z", reinterpret_cast(StatAni::IsDirectory) }, + ani_native_function { "isFIFO", ":Z", reinterpret_cast(StatAni::IsFIFO) }, + ani_native_function { "isFile", ":Z", reinterpret_cast(StatAni::IsFile) }, + ani_native_function { "isSocket", ":Z", reinterpret_cast(StatAni::IsSocket) }, + ani_native_function { "isSymbolicLink", ":Z", reinterpret_cast(StatAni::IsSymbolicLink) }, + }; + + return BindClass(vm, className, methods); +} + +static ani_status BindFileFs(ani_vm *vm) +{ + static const char *className = "Lfile_fs_class/fileIo;"; + + std::vector functions = { + ani_native_function { "doAccessSync", nullptr, reinterpret_cast(AccessAni::AccessSync3) }, + ani_native_function { "unlinkSync", "Lstd/core/String;:I", reinterpret_cast(UnlinkAni::UnlinkSync) }, + ani_native_function { "mkdirSync", "Lstd/core/String;:I", reinterpret_cast(MkdirkAni::MkdirSync0) }, + ani_native_function { "mkdirSync", "Lstd/core/String;Z:I", reinterpret_cast(MkdirkAni::MkdirSync1) }, + ani_native_function { "moveFileSync", "Lstd/core/String;Lstd/core/String;Lstd/core/Int;:V", + reinterpret_cast(MoveAni::MoveFileSync) }, + ani_native_function { "copyFileSync", nullptr, reinterpret_cast(CopyFileAni::CopyFileSync) }, + ani_native_function { "statSync", nullptr, reinterpret_cast(StatAni::StatSync) }, + ani_native_function { "rmdirSync", "Lstd/core/String;:V", reinterpret_cast(RmdirAni::RmdirSync) }, + }; + + return BindClass(vm, className, functions); +} + +ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) +{ + *result = ANI_VERSION_1; + ani_status ret = ANI_OK; + if (ANI_OK != (ret = BindStatMethods(vm))) { + return ret; + }; + + if (ANI_OK != (ret = BindFileFs(vm))) { + return ret; + }; + return ret; +} diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/access_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/access_ani.cpp index e80311d0f..854a8407d 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/access_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/access_ani.cpp @@ -57,17 +57,17 @@ std::optional OptToAccessModeType(const std::optional& mode return ToAccessModeType(mode_index.value()); } -AccessFlagType ToAccessFlagType(int32_t flag_index) +AccessFlag ToAccessFlagType(int32_t flag_index) { switch (flag_index) { case LOCAL_INDEX: - return AccessFlagType::LOCAL_FLAG; + return AccessFlag::LOCAL_FLAG; default: - return AccessFlagType::DEFAULT_FLAG; + return AccessFlag::DEFAULT_FLAG; } } -std::optional OptToAccessFlagType(const std::optional &flag_index) +std::optional OptToAccessFlagType(const std::optional &flag_index) { if (!flag_index.has_value()) { return std::nullopt; @@ -79,7 +79,7 @@ ani_boolean AccessAni::AccessSync3(ani_env *env, [[maybe_unused]] ani_class claz ani_enum_item mode, ani_enum_item flag) { ani_boolean ret = 0; - auto [succPath, pathStr] = TypeConverter::ToUTF8StringPath(env, path); + auto [succPath, pathStr] = TypeConverter::ToUTF8String(env, path); if (! succPath) { HILOGE("Invalid path"); return ret; diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp index 802b6e2fa..e4d1fe4e2 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.cpp @@ -23,7 +23,7 @@ namespace OHOS { namespace FileManagement { -namespace ModuleFileIo { +namespace ModuleFileIO { namespace ANI { using namespace std; @@ -79,6 +79,6 @@ ani_int CloseAni::CloseSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_ } } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.h index 9af6b0732..7c6202f65 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/close_ani.h @@ -20,7 +20,7 @@ namespace OHOS { namespace FileManagement { -namespace ModuleFileIo { +namespace ModuleFileIO { namespace ANI { class CloseAni final { @@ -29,7 +29,7 @@ public: }; } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp index d81e11d1b..c9ce42506 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp @@ -21,7 +21,7 @@ namespace OHOS { namespace FileManagement { -namespace ModuleFileIo { +namespace ModuleFileIO { namespace ANI { using namespace std; @@ -230,6 +230,6 @@ ani_array_ref ListFileAni::ListFileSync(ani_env *env, [[maybe_unused]] ani_class } } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.h index 938266821..63ff7731d 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.h @@ -20,7 +20,7 @@ namespace OHOS { namespace FileManagement { -namespace ModuleFileIo { +namespace ModuleFileIO { namespace ANI { class ListFileAni final { @@ -29,7 +29,7 @@ public: }; } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS 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 e2a6bc6ef..ca260b2d2 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 @@ -28,7 +28,7 @@ namespace ANI { ani_int MkdirkAni::MkdirSync0(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path) { - auto [succ, pathStr] = TypeConverter::ToUTF8StringPath(env, path); + auto [succ, pathStr] = TypeConverter::ToUTF8String(env, path); if (!succ) { HILOGE("Invalid path"); return -1; @@ -43,7 +43,7 @@ ani_int MkdirkAni::MkdirSync0(ani_env *env, [[maybe_unused]] ani_class clazz, an ani_int MkdirkAni::MkdirSync1(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path, ani_boolean recursion) { - auto [succ, pathStr] = ANI::TypeConverter::ToUTF8StringPath(env, path); + auto [succ, pathStr] = ANI::TypeConverter::ToUTF8String(env, path); if (!succ) { HILOGE("Invalid path"); return -1; diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/read_text_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/read_text_ani.cpp index df1ca806a..4b2096afc 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/read_text_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/read_text_ani.cpp @@ -21,7 +21,7 @@ namespace OHOS { namespace FileManagement { -namespace ModuleFileIo { +namespace ModuleFileIO { namespace ANI { using namespace std; @@ -134,6 +134,6 @@ ani_string ReadTextAni::ReadTextSync( } } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/read_text_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/read_text_ani.h index b9f6e7e20..5d3bf6ad1 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/read_text_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/read_text_ani.h @@ -20,7 +20,7 @@ namespace OHOS { namespace FileManagement { -namespace ModuleFileIo { +namespace ModuleFileIO { namespace ANI { class ReadTextAni final { @@ -29,7 +29,7 @@ public: }; } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS 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 13ded3282..cfca74539 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 @@ -28,7 +28,7 @@ namespace ANI { ani_int UnlinkAni::UnlinkSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path) { - auto [succ, pathStr] = TypeConverter::ToUTF8StringPath(env, path); + auto [succ, pathStr] = TypeConverter::ToUTF8String(env, path); if (!succ) { HILOGE("Invalid path"); return -1; diff --git a/interfaces/kits/js/src/mod_fs/properties/mkdir_core.cpp b/interfaces/kits/js/src/mod_fs/properties/mkdir_core.cpp index de19af73e..0f1cfb40e 100644 --- a/interfaces/kits/js/src/mod_fs/properties/mkdir_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/mkdir_core.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -70,8 +70,7 @@ struct AccessArgs { static int UvAccess(const string &path, int mode) { - std::unique_ptr access_req = {new uv_fs_t, - FsUtils::FsReqCleanup}; + std::unique_ptr access_req = { new uv_fs_t, FsUtils::FsReqCleanup }; if (!access_req) { HILOGE("Failed to request heap memory."); return ENOMEM; @@ -129,7 +128,7 @@ static int HandleLocalCheck(const string &path, int mode) { // check if the file of /data/storage/el2/cloud is on the local if (path.find(CLOUDDISK_FILE_PREFIX) == 0) { - char val[2] = {'\0'}; + char val[2] = { '\0' }; if (getxattr(path.c_str(), CLOUD_FILE_LOCATION.c_str(), val, sizeof(val)) < 0) { HILOGI("get cloud file location fail, err: %{public}d", errno); return errno; @@ -168,8 +167,7 @@ static int AccessCore(const string &path, int mode, int flag = DEFAULT_FLAG) static int MkdirCore(const string &path) { - std::unique_ptr mkdir_req = { - new uv_fs_t, FsUtils::FsReqCleanup }; + std::unique_ptr mkdir_req = { new uv_fs_t, FsUtils::FsReqCleanup }; if (!mkdir_req) { HILOGE("Failed to request heap memory."); return ENOMEM; @@ -210,7 +208,7 @@ static int32_t MkdirExec(const string &path, bool recursion, bool hasOption) return ERRNO_NOERR; } -FsResult MkdirCore::DoMkdir(const std::string &path, const std::optional &recursion) +FsResult MkdirCore::DoMkdir(const std::string &path, std::optional recursion) { bool hasOption = false; bool mkdirRecursion = false; 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 aa51d5a07..cc6793693 100644 --- a/interfaces/kits/js/src/mod_fs/properties/mkdir_core.h +++ b/interfaces/kits/js/src/mod_fs/properties/mkdir_core.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -25,7 +25,7 @@ namespace ModuleFileIO { class MkdirCore final { public: - static FsResult DoMkdir(const std::string &path, const std::optional &recursion = std::nullopt); + 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"; diff --git a/interfaces/kits/js/src/mod_hash/ani/hash_ani.cpp b/interfaces/kits/js/src/mod_hash/ani/hash_ani.cpp index c0ffcf458..c8bffc53c 100644 --- a/interfaces/kits/js/src/mod_hash/ani/hash_ani.cpp +++ b/interfaces/kits/js/src/mod_hash/ani/hash_ani.cpp @@ -57,6 +57,6 @@ ani_string HashAni::HashSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani } } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_hash/ani/hash_ani.h b/interfaces/kits/js/src/mod_hash/ani/hash_ani.h index a44088fd0..7b0890fe7 100644 --- a/interfaces/kits/js/src/mod_hash/ani/hash_ani.h +++ b/interfaces/kits/js/src/mod_hash/ani/hash_ani.h @@ -29,7 +29,7 @@ public: }; } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS diff --git a/interfaces/kits/js/src/mod_securitylabel/ani/securitylabel_ani.cpp b/interfaces/kits/js/src/mod_securitylabel/ani/securitylabel_ani.cpp index 29cf1edc0..35f28cc7a 100644 --- a/interfaces/kits/js/src/mod_securitylabel/ani/securitylabel_ani.cpp +++ b/interfaces/kits/js/src/mod_securitylabel/ani/securitylabel_ani.cpp @@ -53,6 +53,6 @@ ani_int SecurityLabelAni::SetSecurityLabelSync( } } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_securitylabel/ani/securitylabel_ani.h b/interfaces/kits/js/src/mod_securitylabel/ani/securitylabel_ani.h index 7586a960f..b99fa8bc1 100644 --- a/interfaces/kits/js/src/mod_securitylabel/ani/securitylabel_ani.h +++ b/interfaces/kits/js/src/mod_securitylabel/ani/securitylabel_ani.h @@ -30,7 +30,7 @@ public: }; } // namespace ANI -} // namespace ModuleFileIo +} // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS -- Gitee