From e613451d77f58ef57393e7a54d90b5db88dab0d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E8=BF=AA?= Date: Tue, 23 May 2023 17:43:42 +0800 Subject: [PATCH] dlopen interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张文迪 --- .../native/file_share/include/file_share.h | 19 ++++++++++++------- .../native/file_share/src/file_share.cpp | 4 ++-- .../file_share_native/file_share_test.cpp | 14 +++++++------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/interfaces/innerkits/native/file_share/include/file_share.h b/interfaces/innerkits/native/file_share/include/file_share.h index 37f76141a..bc138481a 100644 --- a/interfaces/innerkits/native/file_share/include/file_share.h +++ b/interfaces/innerkits/native/file_share/include/file_share.h @@ -68,13 +68,18 @@ const vector LOWER_PATH = { }; } -class FileShare { -public: - FileShare() {} - static int32_t CreateShareFile(const string &uri, uint32_t tokenId, uint32_t flag); - static int32_t DeleteShareFile(uint32_t tokenId, vector sharePathList); - ~FileShare() {} -}; +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif /* End of #ifdef __cplusplus */ + int32_t CreateShareFile(const string &uri, uint32_t tokenId, uint32_t flag); + int32_t DeleteShareFile(uint32_t tokenId, vector sharePathList); +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif /* End of #ifdef __cplusplus */ } // namespace AppFileService } // namespace OHOS diff --git a/interfaces/innerkits/native/file_share/src/file_share.cpp b/interfaces/innerkits/native/file_share/src/file_share.cpp index be352eafd..f39e25512 100644 --- a/interfaces/innerkits/native/file_share/src/file_share.cpp +++ b/interfaces/innerkits/native/file_share/src/file_share.cpp @@ -293,7 +293,7 @@ static int32_t PreparePreShareDir(FileShareInfo &info) return 0; } -int32_t FileShare::CreateShareFile(const string &uri, uint32_t tokenId, uint32_t flag) +int32_t CreateShareFile(const string &uri, uint32_t tokenId, uint32_t flag) { FileShareInfo info; int32_t ret = GetFileShareInfo(uri, tokenId, flag, info); @@ -356,7 +356,7 @@ static void UmountDelUris(vector sharePathList, string currentUid, strin } } -int32_t FileShare::DeleteShareFile(uint32_t tokenId, vector sharePathList) +int32_t DeleteShareFile(uint32_t tokenId, vector sharePathList) { string bundleName, currentUid; int32_t ret = GetTargetInfo(tokenId, bundleName, currentUid); diff --git a/test/unittest/file_share_native/file_share_test.cpp b/test/unittest/file_share_native/file_share_test.cpp index d876fbd8f..3ff1bada1 100644 --- a/test/unittest/file_share_native/file_share_test.cpp +++ b/test/unittest/file_share_native/file_share_test.cpp @@ -66,7 +66,7 @@ namespace { uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; - int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); + int32_t ret = CreateShareFile(uri, tokenId, flag); EXPECT_EQ(ret, E_OK); GTEST_LOG_(INFO) << "FileShareTest-end File_share_CreateShareFile_0000"; } @@ -96,7 +96,7 @@ namespace { uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; - int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); + int32_t ret = CreateShareFile(uri, tokenId, flag); EXPECT_EQ(ret, -EINVAL); GTEST_LOG_(INFO) << "FileShareTest-end File_share_CreateShareFile_0001"; } @@ -123,7 +123,7 @@ namespace { uint32_t tokenId = 100; int32_t flag = 3; - int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); + int32_t ret = CreateShareFile(uri, tokenId, flag); EXPECT_EQ(ret, E_INVALID_ARGUMENT); GTEST_LOG_(INFO) << "FileShareTest-end File_share_CreateShareFile_0002"; } @@ -152,7 +152,7 @@ namespace { uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 3; - int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); + int32_t ret = CreateShareFile(uri, tokenId, flag); EXPECT_EQ(ret, -EINVAL); GTEST_LOG_(INFO) << "FileShareTest-end File_share_CreateShareFile_0003"; } @@ -181,7 +181,7 @@ namespace { uint32_t tokenId = AccessTokenKit::GetHapTokenID(uid, bundleNameB, 0); int32_t flag = 4; - int32_t ret = FileShare::CreateShareFile(uri, tokenId, flag); + int32_t ret = CreateShareFile(uri, tokenId, flag); EXPECT_EQ(ret, -EINVAL); GTEST_LOG_(INFO) << "FileShareTest-end File_share_CreateShareFile_0004"; } @@ -206,7 +206,7 @@ namespace { string bundleNameA = "com.ohos.settingsdata"; string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; sharePathList.push_back(uri); - int32_t ret = FileShare::DeleteShareFile(tokenId, sharePathList); + int32_t ret = DeleteShareFile(tokenId, sharePathList); EXPECT_EQ(ret, E_OK); GTEST_LOG_(INFO) << "FileShareTest-end File_share_DeleteShareFile_0005"; } @@ -227,7 +227,7 @@ namespace { string bundleNameA = "com.ohos.settingsdata"; string uri = "file://" + bundleNameA + "/data/storage/el2/base/files/test.txt"; sharePathList.push_back(uri); - int32_t ret = FileShare::DeleteShareFile(tokenId, sharePathList); + int32_t ret = DeleteShareFile(tokenId, sharePathList); EXPECT_EQ(ret, -EINVAL); GTEST_LOG_(INFO) << "FileShareTest-end File_share_DeleteShareFile_0006"; } -- Gitee