From 477d96d1ffec433be1c6cfd48f5b492624cf95b2 Mon Sep 17 00:00:00 2001 From: jinhaihw Date: Thu, 10 Nov 2022 15:04:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E3=80=90=E5=88=86=E5=B8=83=E5=BC=8F?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E3=80=91=E3=80=90master=E3=80=91=E5=88=86?= =?UTF-8?q?=E5=B8=83=E5=BC=8F=E6=96=87=E4=BB=B6server=E7=AB=AF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=8A=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jinhaihw Change-Id: Ib6808ca5c1180ddd49a34ce44d0a56ba6fb22c23 --- filemanagement/BUILD.gn | 5 +- .../{fileioClient => fileio/client}/BUILD.gn | 0 .../{fileioClient => fileio/client}/Test.json | 0 .../client}/signature/openharmony_sx.p7b | Bin 3392 -> 3428 bytes .../client}/src/main/config.json | 0 .../client}/src/main/js/default/app.js | 0 .../src/main/js/default/i18n/en-US.json | 0 .../src/main/js/default/i18n/zh-CN.json | 0 .../src/main/js/default/pages/index/index.css | 0 .../src/main/js/default/pages/index/index.hml | 0 .../src/main/js/default/pages/index/index.js | 0 .../main/js/default/test/FileioJsUnit.test.js | 11 +- .../src/main/js/default/test/List.test.js | 2 +- .../main/resources/base/element/string.json | 2 +- .../src/main/resources/base/media/icon.png | Bin filemanagement/fileio/server/BUILD.gn | 35 +++ filemanagement/fileio/server/Test.json | 21 ++ .../server/signature/openharmony_sx.p7b | Bin 0 -> 3428 bytes .../fileio/server/src/main/config.json | 89 +++++++ .../server/src/main/js/MainAbility/app.js | 23 ++ .../src/main/js/MainAbility/i18n/en-US.json | 11 + .../src/main/js/MainAbility/i18n/zh-CN.json | 11 + .../main/js/MainAbility/pages/index/index.css | 39 ++++ .../main/js/MainAbility/pages/index/index.hml | 21 ++ .../main/js/MainAbility/pages/index/index.js | 43 ++++ .../js/MainAbility/pages/second/second.css | 39 ++++ .../js/MainAbility/pages/second/second.hml | 21 ++ .../js/MainAbility/pages/second/second.js | 27 +++ .../src/main/js/ServiceAbility/service.js | 218 ++++++++++++++++++ .../main/resources/base/element/string.json | 16 ++ .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes 31 files changed, 625 insertions(+), 9 deletions(-) rename filemanagement/{fileioClient => fileio/client}/BUILD.gn (100%) rename filemanagement/{fileioClient => fileio/client}/Test.json (100%) rename filemanagement/{fileioClient => fileio/client}/signature/openharmony_sx.p7b (51%) rename filemanagement/{fileioClient => fileio/client}/src/main/config.json (100%) rename filemanagement/{fileioClient => fileio/client}/src/main/js/default/app.js (100%) rename filemanagement/{fileioClient => fileio/client}/src/main/js/default/i18n/en-US.json (100%) rename filemanagement/{fileioClient => fileio/client}/src/main/js/default/i18n/zh-CN.json (100%) rename filemanagement/{fileioClient => fileio/client}/src/main/js/default/pages/index/index.css (100%) rename filemanagement/{fileioClient => fileio/client}/src/main/js/default/pages/index/index.hml (100%) rename filemanagement/{fileioClient => fileio/client}/src/main/js/default/pages/index/index.js (100%) rename filemanagement/{fileioClient => fileio/client}/src/main/js/default/test/FileioJsUnit.test.js (97%) rename filemanagement/{fileioClient => fileio/client}/src/main/js/default/test/List.test.js (87%) rename filemanagement/{fileioClient => fileio/client}/src/main/resources/base/element/string.json (81%) rename filemanagement/{fileioClient => fileio/client}/src/main/resources/base/media/icon.png (100%) create mode 100644 filemanagement/fileio/server/BUILD.gn create mode 100644 filemanagement/fileio/server/Test.json create mode 100644 filemanagement/fileio/server/signature/openharmony_sx.p7b create mode 100644 filemanagement/fileio/server/src/main/config.json create mode 100644 filemanagement/fileio/server/src/main/js/MainAbility/app.js create mode 100644 filemanagement/fileio/server/src/main/js/MainAbility/i18n/en-US.json create mode 100644 filemanagement/fileio/server/src/main/js/MainAbility/i18n/zh-CN.json create mode 100644 filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.css create mode 100644 filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.hml create mode 100644 filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.js create mode 100644 filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.css create mode 100644 filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.hml create mode 100644 filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.js create mode 100644 filemanagement/fileio/server/src/main/js/ServiceAbility/service.js create mode 100644 filemanagement/fileio/server/src/main/resources/base/element/string.json create mode 100644 filemanagement/fileio/server/src/main/resources/base/media/icon.png diff --git a/filemanagement/BUILD.gn b/filemanagement/BUILD.gn index d6974c1..f503561 100644 --- a/filemanagement/BUILD.gn +++ b/filemanagement/BUILD.gn @@ -15,7 +15,10 @@ import("//build/ohos_var.gni") group("filemanagement") { testonly = true if (is_standard_system) { - deps = [ "fileioClient:DctsFileioClientTest" ] + deps = [ + "fileio/client:DctsFileioClientTest", + "fileio/server:DctsFileioServer", + ] } else { deps = [ "wifi_standard:ActsWifiJSTest" ] } diff --git a/filemanagement/fileioClient/BUILD.gn b/filemanagement/fileio/client/BUILD.gn similarity index 100% rename from filemanagement/fileioClient/BUILD.gn rename to filemanagement/fileio/client/BUILD.gn diff --git a/filemanagement/fileioClient/Test.json b/filemanagement/fileio/client/Test.json similarity index 100% rename from filemanagement/fileioClient/Test.json rename to filemanagement/fileio/client/Test.json diff --git a/filemanagement/fileioClient/signature/openharmony_sx.p7b b/filemanagement/fileio/client/signature/openharmony_sx.p7b similarity index 51% rename from filemanagement/fileioClient/signature/openharmony_sx.p7b rename to filemanagement/fileio/client/signature/openharmony_sx.p7b index 3d1583ccb8e1d3b5a0aa586ba1475dc3d4a6a118..d00afeff6b13a18a2b5fd8aa9b3d7623aabb6a11 100644 GIT binary patch delta 1034 zcmZ9LO>Em_7{^KGwUo8ALer#8LMq|HN87wk;w2ui@xJ~JbsRT#5=S}IP8_?5V<)jw zyFpVRpk8*NL^~oC#3mIqap15E(l&7d2_#NPz;TCh0S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7~%9^EuBweRS%o_BO+nr5C75hQ~Y14PstzCb4RAnl2G5@)*V}Efa!L;*qOU|B_N_O~(!KWv1CjciOu$62M zbmDt<`>b`XXDjxt+?CTYWcjIK`-^%ezTG%o9<6HMG+wgt%qO&Pve%ZwtmlI%JEr`S zp0{&yvN>bx^1E&C0>kVE_5Cnw}rRz|$LGMvy#TI#5UP@WnXdb0jor(zH9LTP7{Nw|M@(8CmzPAG@^T2Z?oy0}zAE>6se&KQ#7Ca~t%95qJ^+$p`-P zKUXaI4RdSp@9q_OsymMsY`lCR?daL`%L`p;rYkz@mrEPRdb;)BoVngT>a*)-M{s6! z5+9AZ_fmS@RDk-PU)VKC$qBQP)#b literal 0 HcmV?d00001 diff --git a/filemanagement/fileio/server/src/main/config.json b/filemanagement/fileio/server/src/main/config.json new file mode 100644 index 0000000..af66549 --- /dev/null +++ b/filemanagement/fileio/server/src/main/config.json @@ -0,0 +1,89 @@ +{ + "app": { + "bundleName": "com.ohos.fileiotest", + "vendor": "fileio", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "reqPermissions": [ + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + }, + { + "name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + } + ], + "package": "com.ohos.fileiotest", + "name": ".MyApplication", + "mainAbility": "com.ohos.fileiotest.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "js", + "icon": "$media:icon", + "description": "$string:mainability_description", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "js", + + "description": "$string:serviceability_description", + "type": "service", + "visible": true, + "formsEnabled": false + } + ], + "js": [ + { + "pages": [ + "pages/index/index", + "pages/second/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/filemanagement/fileio/server/src/main/js/MainAbility/app.js b/filemanagement/fileio/server/src/main/js/MainAbility/app.js new file mode 100644 index 0000000..bbed207 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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. + */ + +export default { + onCreate() { + console.info("Application onCreate"); + }, + onDestroy() { + console.info("Application onDestroy"); + } +}; diff --git a/filemanagement/fileio/server/src/main/js/MainAbility/i18n/en-US.json b/filemanagement/fileio/server/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 0000000..8feb719 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,11 @@ +{ + "strings": { + "hello": "Hello", + "world": "World", + "page": "Second Page", + "next": "Next Page", + "back": "Back" + }, + "Files": { + } +} \ No newline at end of file diff --git a/filemanagement/fileio/server/src/main/js/MainAbility/i18n/zh-CN.json b/filemanagement/fileio/server/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 0000000..6551d16 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,11 @@ +{ + "strings": { + "hello": "您好", + "world": "世界", + "page": "第二页", + "next": "下一页", + "back": "返回" + }, + "Files": { + } +} \ No newline at end of file diff --git a/filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.css b/filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000..6524ec5 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 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. + */ + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} diff --git a/filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.hml b/filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000..458e777 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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. + */ + +
+ + {{ $t('strings.hello') }} {{ title }} + + +
diff --git a/filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.js b/filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000..4451a64 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 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 router from '@system.router' +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + data: { + title: "" + }, + + onInit() { + this.grantPermission(); + }, + onclick: function () { + router.replace({ + uri: "pages/second/second" + }) + }, + grantPermission() { + console.info('Calc[IndexPage] grantPermission') + let context = featureAbility.getContext() + context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { + console.info('Calc[IndexPage] grantPermission,requestPermissionsFromUser,'+result.requestCode) + + }) + }, + +} + + diff --git a/filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.css b/filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.css new file mode 100644 index 0000000..6524ec5 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.css @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 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. + */ + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +.btn { + width: 50%; + height: 100px; + font-size: 40px; +} diff --git a/filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.hml b/filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.hml new file mode 100644 index 0000000..25118b4 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.hml @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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. + */ + +
+ + {{ $t('strings.page') }} + + +
diff --git a/filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.js b/filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.js new file mode 100644 index 0000000..4abdd40 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/MainAbility/pages/second/second.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 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 router from '@system.router' + +export default { + data: { + title: 'World' + }, + onclick: function () { + router.replace({ + uri: "pages/index/index" + }) + } +} diff --git a/filemanagement/fileio/server/src/main/js/ServiceAbility/service.js b/filemanagement/fileio/server/src/main/js/ServiceAbility/service.js new file mode 100644 index 0000000..13fdc78 --- /dev/null +++ b/filemanagement/fileio/server/src/main/js/ServiceAbility/service.js @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2022 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 rpc from "@ohos.rpc"; +import fileio from '@ohos.fileio'; + +export default { + onStart() { + console.info('FileioServer: onStart') + }, + onStop() { + console.info('FileioServer: onStop') + }, + onCommand(want, startId) { + console.info('FileioServer: onCommand, want: ' + JSON.stringify(want) + ', startId: ' + startId) + }, + onConnect(want) { + console.info('FileioServer: service onConnect called.') + return new Stub("rpcTestAbility") + }, + onDisconnect(want) { + console.info('FileioServer: service onDisConnect called.') + }, + onReconnect(want) { + console.info('FileioServer: service onReConnect called.') + } +} + +function checkDirExists(destDirPath) { + console.info("start check dir :" + destDirPath); + try { + fileio.accessSync(destDirPath, 0); + console.info('------------------- dest dir exists.'); + return true; + } catch (e) { + console.info('------------------- dest dir is not exists.'); + return false; + } +} + +function checkFileExists(destFilePath,) { + console.info("start check file :" + destFilePath); + try { + fileio.accessSync(destFilePath, 0); + console.info('------------------- ' + destFilePath + ' exists.'); + return true; + } catch (e) { + console.info('------------------- ' + destFilePath + ' not exists.'); + return false; + } +} + +function getFileContent(fpath) { + console.info("start get file content:" + fpath); + let content = ""; + try { + content = fileio.readTextSync(fpath); + console.info("-------------- dest file content :" + content); + } catch (e) { + console.info("-------------- read dest file content failed." + e); + } + return content; +} + +const CODE_MK_DIR = 1; +const CODE_RM_DIR = 2; +const CODE_CREATE_FILE = 3; +const CODE_DELETE_FILE = 4; +const CODE_GET_FILE_CONTENT = 5; +const CODE_GET_FILE_STAT = 6; +const CODE_FSYNC_FILE = 7; + +class Stub extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + + onRemoteRequest(code, data, reply, option) { + try { + console.info("onRemoteRequest: " + code) + switch (code) { + case CODE_MK_DIR: + { + console.info("case CODE_MK_DIR start") + let path = data.readString() + console.info("The server's readString result is " + path); + let checkResult = checkDirExists(path); + let result; + if (checkResult == true) { + result = reply.writeString("SUCCESS"); + } else { + result = reply.writeString("Server side dir synchronization creation failed."); + } + + console.info("The server's writeString result is " + result); + return true; + } + case CODE_RM_DIR: + { + console.info("case CODE_RM_DIR start"); + let path = data.readString(); + console.info("The server's readString result is " + path); + + let checkResult = checkDirExists(path); + let result; + if (checkResult == false) { + result = reply.writeString("SUCCESS"); + } else { + result = reply.writeString("Server side dir synchronization deletion failed."); + } + + console.info("The server's writeString result is " + result); + return true; + } + case CODE_CREATE_FILE: + { + console.info("case CODE_CREATE_FILE start"); + let path = data.readString(); + console.info("The server's readString result is " + path); + + let checkResult = checkFileExists(path); + let result; + if (checkResult == true) { + result = reply.writeString("SUCCESS"); + } else { + result = reply.writeString("Server side file synchronization creation failed!"); + } + + console.info("The server's writeString result is " + result); + return true; + } + case CODE_DELETE_FILE: + { + console.info("case CODE_DELETE_FILE start"); + let path = data.readString(); + console.info("The server's readString result is " + path); + + let checkResult = checkFileExists(path); + let result; + if (checkResult == true) { + result = reply.writeString("Server side file synchronization deletion failed."); + } else { + result = reply.writeString("SUCCESS"); + } + + console.info("The server's writeString result is " + result); + return true; + } + case CODE_GET_FILE_CONTENT: + { + console.info("case CODE_GET_FILE_CONTENT start"); + let path = data.readString(); + console.info("The server's readString result is " + path); + checkFileExists(path); + let content =""; + try { + console.info("---------------- start get file content:" + path); + content = getFileContent(path); + console.info("-------------- dest file content :" + content); + } catch (e) { + console.info("-------------- read dest file content failed." + e); + } + + let result = reply.writeString(content); + console.info("The server's writeString result is " + result); + return true; + } + case CODE_GET_FILE_STAT: + { + console.info("case CODE_GET_FILE_STAT start"); + let path = data.readString(); + console.info("The server's readString result is " + path); + let localStat = fileio.statSync(path); + let localStatInfo = "localStat.size = " + localStat.size + ",localStat.mode = " + localStat.mode; + let result = reply.writeString(localStatInfo); + console.info("The server's writeString result is " + result); + return true; + } + case CODE_FSYNC_FILE: + { + console.info("case CODE_FSYNC_FILE start"); + let path = data.readString(); + console.info("The server's readString result is " + path); + let result; + try{ + let fd = fileio.openSync(path, 0o2); + fileio.fsyncSync(fd); + console.info("sync data succeed"); + result = reply.writeString("SUCCESS"); + } catch (e) { + console.info("sync data failed with error:" + e); + result = reply.writeString("FAILED"); + } + console.info("The server's writeString result is " + result); + return true; + } + default: + console.error("default case " + code); + return super.onRemoteMessageRequest(code, data, reply, option); + } + } catch (error) { + console.info("onRemoteMessageRequest: " + error); + } + return false + } +} \ No newline at end of file diff --git a/filemanagement/fileio/server/src/main/resources/base/element/string.json b/filemanagement/fileio/server/src/main/resources/base/element/string.json new file mode 100644 index 0000000..633ba06 --- /dev/null +++ b/filemanagement/fileio/server/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "FileioServer" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + }, + { + "name": "serviceability_description", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/filemanagement/fileio/server/src/main/resources/base/media/icon.png b/filemanagement/fileio/server/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5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y z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y Date: Thu, 10 Nov 2022 15:37:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90=E5=88=86=E5=B8=83=E5=BC=8F?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E3=80=91=E3=80=90master=E3=80=91=E5=88=86?= =?UTF-8?q?=E5=B8=83=E5=BC=8F=E6=96=87=E4=BB=B6server=E7=AB=AF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=8A=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jinhaihw Change-Id: I1bb19b150eb52f820c40ad5a80238cccf7ba0c42 --- .../fileio/client/src/main/js/default/test/List.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filemanagement/fileio/client/src/main/js/default/test/List.test.js b/filemanagement/fileio/client/src/main/js/default/test/List.test.js index 20cca9a..5466440 100644 --- a/filemanagement/fileio/client/src/main/js/default/test/List.test.js +++ b/filemanagement/fileio/client/src/main/js/default/test/List.test.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2022 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