From 8e173f0caad202a849f6db5638f13d031b9cf7e5 Mon Sep 17 00:00:00 2001 From: panqiangbiao Date: Fri, 21 Jan 2022 17:15:47 +0800 Subject: [PATCH 1/2] add filemanager.d.ts Signed-off-by: panqiangbiao --- api/@ohos.filemanager.d.ts | 167 +++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 api/@ohos.filemanager.d.ts diff --git a/api/@ohos.filemanager.d.ts b/api/@ohos.filemanager.d.ts new file mode 100644 index 0000000000..88c373baea --- /dev/null +++ b/api/@ohos.filemanager.d.ts @@ -0,0 +1,167 @@ + /* + * 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 { AsyncCallback } from './basic' + +export default filemanager; + +/** + * @devices phone, tablet, tv, wearable + */ +declare namespace filemanager { + export { listfile }; + export { getRoot }; + export { createFile }; + export { ListFileParam }; + export { FileInfo }; + export { DevInfo }; +} + +/** + * listfile. + * + * @note N/A + * @sysCap SystemCapability.FileManagement.FileManagerService + * @since 8 + * @permission N/A + * @function listfile + * @param {ListFileParam} param - listfile param. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function listfile(param: ListFileParam): Promise; +declare function listfile(param: ListFileParam, AsyncCallback): void; + +/** + * getRoot. + * + * @note N/A + * @sysCap SystemCapability.FileManagement.FileManagerService + * @since 8 + * @permission N/A + * @function getRoot + * @param {DevInfo} dev - dev name. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function getRoot(dev: DevInfo): Promise; +declare function getRoot(dev: DevInfo, callback: AsyncCallback): void; + +/** + * createFile. + * + * @note N/A + * @sysCap SystemCapability.FileManagement.FileManagerService + * @since 8 + * @permission N/A + * @function createFile + * @param {DevInfo} dev - dev name. + * @param {string} filename- file name. + * @param {string} path - album uri. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws {TypedError} Parameter check failed + */ +declare function createFile(dev: DevInfo, filename: string, path: string): Promise; +declare function createFile(dev: DevInfo, filename: string, path: string, callback: AsyncCallback): void; + +/** + * ListFileParam + * @note N/A + * @sysCap SystemCapability.FileManagement.FileManagerService + * @since 8 + * @permission N/A + * @devices phone, tablet, tv, wearable + */ + declare interface ListFileParam { + /** + * dev info + */ + dev: DevInfo; + /** + * file type + */ + type: string; + /** + * path + */ + path: string; + /** + * offset + */ + offset?: number; + /** + * count + */ + count?: number; + } + +/** + * FileInfo + * @note N/A + * @sysCap SystemCapability.FileManagement.FileManagerService + * @since 8 + * @permission N/A + * @devices phone, tablet, tv, wearable + */ +declare interface FileInfo { + /** + * @type {string} + * @readonly + */ + name: string; + /** + * @type {string} + * @readonly + */ + path: string; + /** + * @type {string} + * @readonly + */ + type: string; + /** + * @type {string} + * @readonly + */ + size: number; + /** + * @type {string} + * @readonly + */ + addedTime: number; + /** + * @type {string} + * @readonly + */ + modifiedTime: number; +} + +/** + * DevInfo + * @note N/A + * @sysCap SystemCapability.FileManagement.FileManagerService + * @since 8 + * @permission N/A + * @devices phone, tablet, tv, wearable + */ + declare interface DevInfo { + /** + * @type {string} + */ + name: string; + } -- Gitee From b65b2e5e7486968046112027bc86628aa94629e9 Mon Sep 17 00:00:00 2001 From: panqiangbiao Date: Wed, 26 Jan 2022 09:45:48 +0800 Subject: [PATCH 2/2] modify type into options Signed-off-by: panqiangbiao --- api/@ohos.filemanager.d.ts | 49 +++++++++----------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/api/@ohos.filemanager.d.ts b/api/@ohos.filemanager.d.ts index 88c373baea..006f4f7ff4 100644 --- a/api/@ohos.filemanager.d.ts +++ b/api/@ohos.filemanager.d.ts @@ -21,29 +21,33 @@ export default filemanager; * @devices phone, tablet, tv, wearable */ declare namespace filemanager { - export { listfile }; + export { listFile }; export { getRoot }; export { createFile }; - export { ListFileParam }; export { FileInfo }; export { DevInfo }; } /** - * listfile. + * listFile. * * @note N/A * @sysCap SystemCapability.FileManagement.FileManagerService * @since 8 * @permission N/A - * @function listfile - * @param {ListFileParam} param - listfile param. + * @function listFile + * @param {DevInfo} dev - dev name. + * @param {string} path - path. + * @param {Object} options - options + * @param {string} [options.type] - type. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.count = 0] - count. * @param {AsyncCallback} [callback] - callback. * @returns {void | Promise} no callback return Promise otherwise return void * @throws {TypedError} Parameter check failed */ -declare function listfile(param: ListFileParam): Promise; -declare function listfile(param: ListFileParam, AsyncCallback): void; +declare function listFile(dev: DevInfo, path: string, options:{type: string, offset?: number, count?: number}): Promise; +declare function listFile(dev: DevInfo, path: string, options:{type: string, offset?: number, count?: number}, AsyncCallback): void; /** * getRoot. @@ -79,37 +83,6 @@ declare function getRoot(dev: DevInfo, callback: AsyncCallback): voi declare function createFile(dev: DevInfo, filename: string, path: string): Promise; declare function createFile(dev: DevInfo, filename: string, path: string, callback: AsyncCallback): void; -/** - * ListFileParam - * @note N/A - * @sysCap SystemCapability.FileManagement.FileManagerService - * @since 8 - * @permission N/A - * @devices phone, tablet, tv, wearable - */ - declare interface ListFileParam { - /** - * dev info - */ - dev: DevInfo; - /** - * file type - */ - type: string; - /** - * path - */ - path: string; - /** - * offset - */ - offset?: number; - /** - * count - */ - count?: number; - } - /** * FileInfo * @note N/A -- Gitee