From fc04fa3e9588d5a298a15131df127c4a05488c5c Mon Sep 17 00:00:00 2001 From: wangke Date: Tue, 25 Jan 2022 17:09:53 +0800 Subject: [PATCH 1/3] update README_ZH.md & add OAT.xml Signed-off-by: wangke --- OAT.xml | 65 +++++++++++++++++++ README.md | 36 ---------- README_zh.md => README_ZH.md | 8 ++- .../remote_file_share/remote_file_share.cpp | 11 ++++ ohos.build | 14 ---- 5 files changed, 81 insertions(+), 53 deletions(-) create mode 100644 OAT.xml delete mode 100644 README.md rename README_zh.md => README_ZH.md (63%) delete mode 100644 ohos.build diff --git a/OAT.xml b/OAT.xml new file mode 100644 index 000000000..b736383c3 --- /dev/null +++ b/OAT.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + diff --git a/README.md b/README.md deleted file mode 100644 index 65de95fde..000000000 --- a/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# storage_app_fileshare_manager - -#### 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/) diff --git a/README_zh.md b/README_ZH.md similarity index 63% rename from README_zh.md rename to README_ZH.md index 2671214b4..faaa94129 100644 --- a/README_zh.md +++ b/README_ZH.md @@ -13,12 +13,14 @@ ## **说明** ### 接口说明 -**表1**应用文件服务接口说明 +**表1** 应用文件服务接口说明 | **接口名** | **说明** | | --- | --- | -| createSharePath(fd: number, cid: string, callback: AsyncCallback\): void \| Promise\ | 将文件fd与设备cid传递给分布式文件系统,创建跨设备分享路径 | +| createSharePath(fd: number, cid: string, callback: AsyncCallback\): void
createSharePath(fd: number, cid: string): Promise\ | 将文件fd与设备cid传递给分布式文件系统,创建跨设备分享路径 | ### 使用说明 -- createSharePath +- createSharePath + +通过该接口进行操作前,需要先打开分享文件获取fd并指定分享目标设备号cid,调用createSharePath创建分享路径后,远端设备可以直接通过该路径打开本地分享文件,同时具备读写该文件能力。 ``` import remotefileshare from'@ohos.remotefileshare' diff --git a/interfaces/kits/js/remote_file_share/remote_file_share.cpp b/interfaces/kits/js/remote_file_share/remote_file_share.cpp index a36e68752..21e5cf69f 100644 --- a/interfaces/kits/js/remote_file_share/remote_file_share.cpp +++ b/interfaces/kits/js/remote_file_share/remote_file_share.cpp @@ -56,15 +56,18 @@ struct AddonData { void ExecuteWork(napi_env env, void *data) { struct AddonData *addonData = (struct AddonData *)data; +#ifdef CONFIG_PERMISSION struct hmdfs_share_control sc; int32_t err = 0; int32_t dirFd; std::string packagePath = "/mnt/hmdfs/0/device_view/local/data/com.example.filesharetestcase"; std::string sharePath = packagePath + "/.share"; +#endif if (addonData->status == 0) return; +#ifdef CONFIG_PERMISSION dirFd = open(sharePath.c_str(), O_RDONLY); if (dirFd < 0) { addonData->status = 0; @@ -82,6 +85,14 @@ void ExecuteWork(napi_env env, void *data) } close(dirFd); +#else + if (addonData->fd <= 0) + { + addonData->err = EBADF; + addonData->status = 0; + return; + } +#endif } void WorkComplete(napi_env env, napi_status status, void *data) diff --git a/ohos.build b/ohos.build deleted file mode 100644 index 0ce348547..000000000 --- a/ohos.build +++ /dev/null @@ -1,14 +0,0 @@ -{ - "subsystem": "filemanagement", - "parts": { - "app_file_service": { - "variants": [ - "wearable", - "phone" - ], - "module_list": [ - "//foundation/filemanagement/app_file_service/interfaces/kits/js/:remotefileshare" - ] - } - } -} \ No newline at end of file -- Gitee From 082fede07fdcd066c61617ef4822b161509e4c26 Mon Sep 17 00:00:00 2001 From: wangke Date: Tue, 25 Jan 2022 17:40:01 +0800 Subject: [PATCH 2/3] update README_ZH.md & add bundle.json Signed-off-by: wangke --- BUILD.gn | 18 ++++++++++++++++++ README_ZH.md | 18 ++++++++---------- bundle.json | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 BUILD.gn create mode 100644 bundle.json diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 000000000..af0c7ab49 --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2021 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") + +group("libremotefileshare") { + deps = [ "//foundation/filemanagement/app_file_service/interfaces/kits/js:remotefileshare" ] +} \ No newline at end of file diff --git a/README_ZH.md b/README_ZH.md index faaa94129..05051acc6 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -18,19 +18,17 @@ | --- | --- | | createSharePath(fd: number, cid: string, callback: AsyncCallback\): void
createSharePath(fd: number, cid: string): Promise\ | 将文件fd与设备cid传递给分布式文件系统,创建跨设备分享路径 | ### 使用说明 -- createSharePath +createSharePath接口为分享文件fd创建能够跨设备访问的分布式路径,异步返回创建结果,设备号cid用于指定分享设备。 -通过该接口进行操作前,需要先打开分享文件获取fd并指定分享目标设备号cid,调用createSharePath创建分享路径后,远端设备可以直接通过该路径打开本地分享文件,同时具备读写该文件能力。 +示例: ``` -import remotefileshare from'@ohos.remotefileshare' +import remotefileshare from '@ohos.remotefileshare' + +remotefileshare.createSharePath(fd, cid, function(err, path) { + // callback +}); remotefileshare.createSharePath(fd, cid).then(function(path) { // promise }); - -remotefileshare.createSharePath(fd, cid, function(err, path) { - // aysnc -}) -``` - -## **相关仓** \ No newline at end of file +``` \ No newline at end of file diff --git a/bundle.json b/bundle.json new file mode 100644 index 000000000..93b2a0e87 --- /dev/null +++ b/bundle.json @@ -0,0 +1,30 @@ +{ + "name": "@ohos/app_file_service", + "description": "App file service provides sharing and file management for apps", + "optional": "false", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "foundation/filemanagement/app_file_service" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "app_file_service", + "subsystem": "filemanagement", + "syscap": [ + "SystemCapability.FileManagement.RemoteFileShare" + ], + "adapted_system_type": [ + "standard" + ], + "rom": "", + "ram": "", + "build": { + "sub_component": [ + "//foundation/filemanagement/app_file_service:libremotefileshare" + ] + } + } +} -- Gitee From 39cc342f5a33e58973c74166047e68d55af4812e Mon Sep 17 00:00:00 2001 From: wangke Date: Thu, 27 Jan 2022 19:08:18 +0800 Subject: [PATCH 3/3] delete CONFIG_PERMISSION Signed-off-by: wangke --- .../js/remote_file_share/remote_file_share.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/interfaces/kits/js/remote_file_share/remote_file_share.cpp b/interfaces/kits/js/remote_file_share/remote_file_share.cpp index 21e5cf69f..39b6ed994 100644 --- a/interfaces/kits/js/remote_file_share/remote_file_share.cpp +++ b/interfaces/kits/js/remote_file_share/remote_file_share.cpp @@ -56,18 +56,12 @@ struct AddonData { void ExecuteWork(napi_env env, void *data) { struct AddonData *addonData = (struct AddonData *)data; -#ifdef CONFIG_PERMISSION struct hmdfs_share_control sc; int32_t err = 0; int32_t dirFd; std::string packagePath = "/mnt/hmdfs/0/device_view/local/data/com.example.filesharetestcase"; std::string sharePath = packagePath + "/.share"; -#endif - if (addonData->status == 0) - return; - -#ifdef CONFIG_PERMISSION dirFd = open(sharePath.c_str(), O_RDONLY); if (dirFd < 0) { addonData->status = 0; @@ -85,14 +79,6 @@ void ExecuteWork(napi_env env, void *data) } close(dirFd); -#else - if (addonData->fd <= 0) - { - addonData->err = EBADF; - addonData->status = 0; - return; - } -#endif } void WorkComplete(napi_env env, napi_status status, void *data) -- Gitee