From 2bb77fcf129b05c78765e0d80ada3d8fb982ea47 Mon Sep 17 00:00:00 2001 From: liuzerun Date: Wed, 28 Jun 2023 04:10:10 +0000 Subject: [PATCH 1/5] test --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b7b50492e..a0731e923 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,5 @@ Software architecture description 4. The most valuable open source project [GVP](https://gitee.com/gvp) 5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) 6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) + +add -- Gitee From 4a2c96d77a4c20c6ea3fecf4589f73f274aba7c0 Mon Sep 17 00:00:00 2001 From: liuzerun Date: Wed, 28 Jun 2023 12:49:55 +0000 Subject: [PATCH 2/5] file_remote_share_add --- .../native/file_remote_share/BUILD.gn | 40 +++++++ .../include/file_remote_share.h | 48 ++++++++ .../src/file_remote_share.cpp | 109 ++++++++++++++++++ 3 files changed, 197 insertions(+) create mode 100644 interfaces/innerkits/native/file_remote_share/BUILD.gn create mode 100644 interfaces/innerkits/native/file_remote_share/include/file_remote_share.h create mode 100644 interfaces/innerkits/native/file_remote_share/src/file_remote_share.cpp diff --git a/interfaces/innerkits/native/file_remote_share/BUILD.gn b/interfaces/innerkits/native/file_remote_share/BUILD.gn new file mode 100644 index 000000000..6f9b24ff6 --- /dev/null +++ b/interfaces/innerkits/native/file_remote_share/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (c) 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 +# +# 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. + +import("//build/ohos.gni") + +config("file_share_config") { + visibility = [ ":*" ] + include_dirs = [ + "include", + "../common", + ] +} + +ohos_shared_library("fileshare_native") { + sources = [ "src/file_share.cpp" ] + + public_configs = [ ":file_share_config" ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_base:zuri", + "access_token:libaccesstoken_sdk", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + ] + + part_name = "app_file_service" + subsystem_name = "filemanagement" +} diff --git a/interfaces/innerkits/native/file_remote_share/include/file_remote_share.h b/interfaces/innerkits/native/file_remote_share/include/file_remote_share.h new file mode 100644 index 000000000..c656872bc --- /dev/null +++ b/interfaces/innerkits/native/file_remote_share/include/file_remote_share.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 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 + * + * 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 APP_FILE_SERVICE_FILE_REMOTE_SHARE +#define APP_FILE_SERVICE_FILE_REMOTE_SHARE + +#include +#include + +namespace OHOS { +namespace AppFileService { +using namespace std; + +#define HMDFS_IOC 0xf2 +#define HMDFS_IOC_GET_DRAG_PATH _IOR(HMDFS_IOC, 3, __u32) + +namespace { +const int URI_BUNDLENAME_BEGIN = 7; +const int LOOP_TIMES = 6; +const int SRC_USERID_INSERT = 14; +const int SRC_BUNDLENAME_INSERT = 20; +const int DST_BUNDLENAME_INSERT = 48; +const int MAX_PATH_LENGTH = 255; +const string FILE_SCHEME = "file://"; +const string SRC_DIR_MASK = "/data/app/el2//base//files/"; +const string DST_DIR_MASK = "/data/service/el2/hmdfs/account/merge_view/data//"; +const std::string SHAER_PATH_HEAD = "/mnt/hmdfs/"; +const std::string SHAER_PATH_MID = "/account/merge_view/data/remote_share.txt"; +} + +static string ChangeUriFromLocalToCloud (const string &uriStr, const int userId); + +} // namespace AppFileService +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native/file_remote_share/src/file_remote_share.cpp b/interfaces/innerkits/native/file_remote_share/src/file_remote_share.cpp new file mode 100644 index 000000000..b39000d32 --- /dev/null +++ b/interfaces/innerkits/native/file_remote_share/src/file_remote_share.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (c) 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 + * + * 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 "file_drag.h" + +#include +#include +#include +#include +#include +#include + +namespace OHOS { +namespace AppFileService { + +struct hmdfs_drag_info{ + unsigned long localLen; + unsigned long localPath; + unsigned long cloudLen; + unsigned long cloudPath; +}; + +static string GetBundleName (const string &uriStr) +{ + int bundlenameEnd = uriStr.find('/', URI_BUNDLENAME_BEGIN); + return uriStr.substr(URI_BUNDLENAME_BEGIN, + bundlenameEnd - URI_BUNDLENAME_BEGIN); + +} + +static string GetFilesName (const string &uriStr) +{ + int filesEnd = BUNDLENAME_BEGIN - 1; + for(int i = 0; i < LOOP_TIMES; i++){ + filesEnd = uriStr.find('/', filesEnd + 1); + } + return uriStr.substr(filesEnd + 1, + int(uri.size()) - filesEnd); +} + +static string CreateSrcStr(const string &bundleName, const int &userId, const string &filesName) +{ + string srcStr = SRC_DIR_MASK; + + srcStr.substr(SRC_BUNDLENAME_INSERT, bundleName); + srcStr.substr(SRC_USERID_INSERT, to_string(userId)); + srcStr += filesName; + + return srcStr; +} + +static string CreateDstStr(const string &bundleName, const string &filesName) +{ + string dstStr = DST_DIR_MASK; + + dstStr.substr(DST_BUNDLENAME_INSERT, bundleName); + dstStr += filesName; + + return dstStr; +} + +static GetSharePath(const int &userId) +{ + return SHAER_PATH_HEAD + to_string(userId) + SHAER_PATH_MID; +} + +static string ChangeUriFromLocalToCloud (const string &uriStr, const int &userId) +{ + const char *srcCh; + const char *dstCh; + string bundleName = GetBundleName(uriStr); + string filesName = GetFilesName(uriStr); + + string srcStr = CreateSrcStr(bundleName, userId, filesName); + string dstStr = CreateDstStr(bundleName, filesName); + + string dstUriStr = FILE_SCHEME + bundleName + dstStr; + + file hmdfsDevFd = open(GetSharePath(userId), O_RDONLY); + + hmdfs_drag_info hdi; + + srcCh = srcStr.c_str(); + dstCh = dstStr.c_str(); + + hdi.localLen = MAX_PATH_LENGTH; + hdi.localPath = static_cast (srcCh);; + hdi.cloudLen = MAX_PATH_LENGTH; + hdi.cloudPath = static_cast (dstCh); + + ioctl(hmdfsDevFd, HMDFS_IOC_GET_DRAG_PATH, hdi); + + return dstUriStr; +} + +} +} \ No newline at end of file -- Gitee From 841fe8bf032395e15fd9aad877dac0acd6059723 Mon Sep 17 00:00:00 2001 From: runrunya Date: Thu, 29 Jun 2023 04:48:36 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20READ?= =?UTF-8?q?ME.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index a0731e923..000000000 --- a/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# app_file_service - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) - -add -- Gitee From 55abd4bcfec1c38fb4d02c99d22b1979e6fb3054 Mon Sep 17 00:00:00 2001 From: runrunya Date: Thu, 29 Jun 2023 04:56:45 +0000 Subject: [PATCH 4/5] =?UTF-8?q?Revert=20"=E5=88=A0=E9=99=A4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=20README.md"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 841fe8bf032395e15fd9aad877dac0acd6059723. --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..a0731e923 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# app_file_service + +#### Description +{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} + +#### Software Architecture +Software architecture description + +#### Installation + +1. xxxx +2. xxxx +3. xxxx + +#### Instructions + +1. xxxx +2. xxxx +3. xxxx + +#### Contribution + +1. Fork the repository +2. Create Feat_xxx branch +3. Commit your code +4. Create Pull Request + + +#### Gitee Feature + +1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md +2. Gitee blog [blog.gitee.com](https://blog.gitee.com) +3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) +4. The most valuable open source project [GVP](https://gitee.com/gvp) +5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) +6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) + +add -- Gitee From 44303a323a982c0c742ddf02751bee2d3fa7e735 Mon Sep 17 00:00:00 2001 From: liuzerun Date: Thu, 29 Jun 2023 06:38:19 +0000 Subject: [PATCH 5/5] file_remote_share Signed-off-by: liuzerun --- .../include/file_remote_share.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/interfaces/innerkits/native/file_remote_share/include/file_remote_share.h b/interfaces/innerkits/native/file_remote_share/include/file_remote_share.h index c656872bc..7ad4b0acf 100644 --- a/interfaces/innerkits/native/file_remote_share/include/file_remote_share.h +++ b/interfaces/innerkits/native/file_remote_share/include/file_remote_share.h @@ -26,21 +26,7 @@ using namespace std; #define HMDFS_IOC 0xf2 #define HMDFS_IOC_GET_DRAG_PATH _IOR(HMDFS_IOC, 3, __u32) -namespace { -const int URI_BUNDLENAME_BEGIN = 7; -const int LOOP_TIMES = 6; -const int SRC_USERID_INSERT = 14; -const int SRC_BUNDLENAME_INSERT = 20; -const int DST_BUNDLENAME_INSERT = 48; -const int MAX_PATH_LENGTH = 255; -const string FILE_SCHEME = "file://"; -const string SRC_DIR_MASK = "/data/app/el2//base//files/"; -const string DST_DIR_MASK = "/data/service/el2/hmdfs/account/merge_view/data//"; -const std::string SHAER_PATH_HEAD = "/mnt/hmdfs/"; -const std::string SHAER_PATH_MID = "/account/merge_view/data/remote_share.txt"; -} - -static string ChangeUriFromLocalToCloud (const string &uriStr, const int userId); +static string ChangeUriFromLocalToCloud (const string &uriStr, const int &userId); } // namespace AppFileService } // namespace OHOS -- Gitee