From d9513e861b3c19a137049e30a1ea52ff5d535580 Mon Sep 17 00:00:00 2001 From: xingshenjie Date: Tue, 18 Feb 2025 10:42:41 +0800 Subject: [PATCH] Adapter ardroid for arikui Signed-off-by: xingshenjie --- file_api.gni | 1 + interfaces/kits/js/BUILD.gn | 3 +++ interfaces/kits/js/src/mod_fs/common_func.cpp | 4 ++-- interfaces/kits/js/src/mod_fs/common_func.h | 6 +++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/file_api.gni b/file_api.gni index 7fc94ace6..65ec37d88 100644 --- a/file_api.gni +++ b/file_api.gni @@ -23,3 +23,4 @@ utils_path = "${file_api_path}/utils" use_mac = "${current_os}_${current_cpu}" == "mac_x64" || "${current_os}_${current_cpu}" == "mac_arm64" use_mingw_win = "${current_os}_${current_cpu}" == "mingw_x86_64" +use_android = "${current_os}" diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 444fb9c07..d26a8e72d 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -181,6 +181,9 @@ ohos_shared_library("fs") { if (use_mac) { defines = [ "IOS_PLATFORM" ] } + if (use_android) { + defines = [ "ANDROID_PLATFORM" ] + } external_deps = [ "hilog:libhilog", diff --git a/interfaces/kits/js/src/mod_fs/common_func.cpp b/interfaces/kits/js/src/mod_fs/common_func.cpp index 2b5d03eb2..30a9eba43 100644 --- a/interfaces/kits/js/src/mod_fs/common_func.cpp +++ b/interfaces/kits/js/src/mod_fs/common_func.cpp @@ -34,7 +34,7 @@ #include "filemgmt_libhilog.h" #include "filemgmt_libn.h" #include "file_utils.h" -#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) +#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) !defined(ANDROID_PLATFORM) #include "ipc_skeleton.h" #include "tokenid_kit.h" #endif @@ -350,7 +350,7 @@ string CommonFunc::Decode(const std::string &uri) return outPutStream.str(); } -#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) +#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) !defined(ANDROID_PLATFORM) bool IsNumeric(const string &str) { if (str.empty()) { diff --git a/interfaces/kits/js/src/mod_fs/common_func.h b/interfaces/kits/js/src/mod_fs/common_func.h index b94235216..3eab1d523 100644 --- a/interfaces/kits/js/src/mod_fs/common_func.h +++ b/interfaces/kits/js/src/mod_fs/common_func.h @@ -19,7 +19,7 @@ #include "fd_guard.h" #include "n_val.h" #include "uv.h" -#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) +#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) !defined(ANDROID_PLATFORM) #include "iremote_broker.h" #include "file_uri.h" #endif @@ -64,7 +64,7 @@ struct FileInfo { std::unique_ptr fdg = { nullptr }; }; -#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) +#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) !defined(ANDROID_PLATFORM) class FileIoToken : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.fileio.open"); @@ -102,7 +102,7 @@ struct CommonFunc { static std::string GetModeFromFlags(unsigned int flags); static bool CheckPublicDirPath(const std::string &sandboxPath); static std::string Decode(const std::string &uri); -#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) +#if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) !defined(ANDROID_PLATFORM) static bool GetAndCheckUserId(Uri* uri, std::string &userId); static bool IsSystemApp(); #endif -- Gitee