diff --git a/file_api.gni b/file_api.gni index 7fc94ace62004264471a75000deb0900070d3727..65ec37d88216321c640466e9452673a7f28be035 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 444fb9c07fe99c6055a115a22981904cf5bfed91..d26a8e72d319023611f9c5cf8ad43cb1b6172bc2 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 2b5d03eb269216d78737a0f544ffec7e674aeee1..30a9eba43cb56b9e5c189330dc20cda329e5812e 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 b94235216c2f639c114f08fd6048076a5f686186..3eab1d52357f3cf660c2f1c1198f1001c0d33613 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